听灌多
  • 板块灌水区
  • 楼主yexuanqi
  • 当前回复7
  • 已保存回复7
  • 发布时间2024/9/25 21:54
  • 上次更新2024/9/26 11:47:10
查看原帖
听灌多
1217860
yexuanqi楼主2024/9/25 21:54

求条,P1358,30pts

#include<bits/stdc++.h>
using namespace std;

const int MOD = 10007;

int A(int m, int n)
{
	int ans = 1;
	for(int i = m, j = 1; j <= n; i --, j ++) ans = ans * i % MOD;
	return ans;
}
int C(int m, int n)
{
	if(m < n) return 0;
	return A(m, n) / A (n, n) % MOD;
}
int main()
{
	int n, m, sum = 1, a, tot = 0;
	cin >> n >> m;
	while(m --)
	{
		cin >> a;
		sum = sum * C(n, a) % MOD, n -= a, tot += a;
	}
	cout << sum % MOD << endl;
	
	return 0;
}

MOD乱加了还错((

2024/9/25 21:54
加载中...