Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
求助啊···为啥老是WA啊···麻烦看看哪错了啊···#include<stdio.h> #include<stdlib.h> #include<string.h> #include<math.h> int a[10000]; int i,j,sum,k=0,n,t; int fun(int n) { int m=(int)sqrt(n); for(j=2;j<=m;j++) if(n%j==0) break; if(j>m){ a[k]=n;k++;} return 0; } int main() { for(i=2;i<=10000;i++) fun(i); // for(i=0;i<k;i++) // printf("%d ",a[i]); // printf("\n"); // printf("%d\n",k); while(scanf("%d",&n)!=EOF) { if(n==0)break; if(n>9973)printf("0\n"); else { sum=0; for(i=0;i<=n;i++) { if(a[i]>n)break; if(a[i]==n) {sum++;break;} } while(i>0) { t=n; j=i--; while(j>0&&(t-a[j-1])>=0) { t-=a[j-1]; if (t<0) break; else if (t==0) sum++; j--; } } printf("%d\n",sum); } } /* */ system("pause"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator