hdu 1284
此题我觉得非常的亢爹,用while(cin>>n)输入肯定wa,原因不详,所以此题只能用while(scanf("%d",&n)!=EOF),作为输入语句。
ac代码:
View Code
#include<iostream> using namespace std; const int M=38000; int dp[M]; int main() { /*freopen("in.txt","r",stdin); freopen("out1.txt","w",stdout);*/ int i,j; dp[0]=1; for(i=1;i<=3;i++) { for(j=i;j<=M;j++) { dp[j]=dp[j-i]+dp[j]; } } int n; while(scanf("%d",&n)!=EOF) { printf("%d\n",dp[n]); } return 0; }