2 条题解
-
0
#include <bits/stdc++.h> using namespace std; const int N = 4002; const long long mod = 2147483648; int n; long long f[N];//保险起见,防止爆 int int main() {//f_i : 数 i 拆分为任意个数相加的形式的方案总数 ios::sync_with_stdio(0); //关闭同步流 cin.tie(0), cout.tie(0); //等待时间设为零 f[0] = 1; //注意将 f_0 初始化为 1 cin >> n; for (int i = 1; i <= n; i++) //枚举拆分数 for (int j = i; j <= n; j++) //枚举被拆分数 f[j] = (f[j] + f[j - i]) % mod; //状态转移 cout << f[n] - 1;//记得除去本身 return 0; } -
0
#include <bits/stdc++.h> using namespace std; const int N = 4002; const long long mod = 2147483648; int n; long long f[N];//保险起见,防止爆 int int main() {//f_i : 数 i 拆分为任意个数相加的形式的方案总数 ios::sync_with_stdio(0); //关闭同步流 cin.tie(0), cout.tie(0); //等待时间设为零 f[0] = 1; //注意将 f_0 初始化为 1 cin >> n; for (int i = 1; i <= n; i++) //枚举拆分数 for (int j = i; j <= n; j++) //枚举被拆分数 f[j] = (f[j] + f[j - i]) % mod; //状态转移 cout << f[n] - 1;//记得除去本身 return 0; }
- 1
信息
- ID
- 1366
- 时间
- 1000ms
- 内存
- 64MiB
- 难度
- 3
- 标签
- 递交数
- 83
- 已通过
- 43
- 上传者