社区讨论
这道题的方案数会爆吗?从25分到90分,自己蒙出来的做法。不是很会计算数据范围
P2822[NOIP 2016 提高组] 组合数问题参与者 4已保存回复 3
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 3 条
- 当前快照
- 1 份
- 快照标识符
- @lo2suvsh
- 此快照首次捕获于
- 2023/10/23 19:13 2 年前
- 此快照最后确认于
- 2023/10/23 19:13 2 年前
CPP
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 2e3 + 10;
int C[N][N];
int n, m;
int main()
{
int t, k;
cin >> t >> k;
while (t --)
{
cin >> n >> m;
int cnt=0;
for (int i=0; i <= n; i ++)
{
C[i][0] = C[i][i] = 1;
for (int j=1; j <= min(i, m); j ++)
{
C[i][j] = (C[i-1][j] + C[i-1][j-1]) % k;
if (C[i][j] == 0)
cnt ++;
}
}
cout << cnt << endl;
}
return 0;
}
回复
共 3 条回复,欢迎继续交流。
正在加载回复...