传送门:
http://acm.hdu.edu.cn/showproblem.php?pid=1284
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 12335 Accepted Submission(s): 7453
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define max_v 32768 int c1[max_v]; int c2[max_v]; int main() { for(int i=0;i<max_v;i++) { c1[i]=1; c2[i]=0; } for(int i=2; i<=3; i++) { for(int j=0; j<max_v; j++) { for(int y=0; y+j<max_v; y+=i) { c2[j+y]+=c1[j]; } } for(int j=0; j<max_v; j++) { c1[j]=c2[j]; c2[j]=0; } } int x; while(~scanf("%d",&x)) { printf("%d\n",c1[x]); } return 0; }
原文:https://www.cnblogs.com/yinbiao/p/9326254.html