1 solutions
-
0
01背包
#include <bits/stdc++.h> using namespace std; int prime[20019],opt,ans; bool s[2019]; void ols(){ for(int i=2;i<=2019;i++){ if(!s[i]) prime[opt++]=i; for(int j=0;j<opt&&prime[j]*i<=2019;j++){ s[prime[j]*i]=1; if(i%prime[j]==0) break; } } } long long f[2019]; int main(){ ols(); f[0]=1; for(int i=0;i<opt;i++){ for(int j=2019;j>=prime[i];j--){//从大到小,防止重复加入 f[j]+=f[j-prime[i]]; } } cout<<f[2019]; return 0; }
- 1
Information
- ID
- 58
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 6
- Tags
- # Submissions
- 27
- Accepted
- 11
- Uploaded By