1 solutions
-
3
#include <bits/stdc++.h> using namespace std; const int maxn = 1010; int n, p[maxn], cnt; long long f[maxn]; bool np[maxn]; void init() { for (int i = 2; i <= n; i ++) { if (!np[i]) { p[cnt++] = i; for (int j = i; j <= n/i; j ++) { np[i*j] = true; } } } } void d(int c) { for (int i = c; i <= n; i ++) f[i] += f[i-c]; } int main() { cin >> n; init(); f[0] = 1; for (int i = 0; i < cnt && p[i] <= n; i ++) d(p[i]); cout << f[n] << endl; return 0; }
- 1
Information
- ID
- 1048
- Time
- 1000ms
- Memory
- 125MiB
- Difficulty
- 7
- Tags
- # Submissions
- 36
- Accepted
- 8
- Uploaded By