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 |
谁能帮我看看,为什么会RE???????#include<stdio.h> #include<math.h> int jud(int n) { int i,k; if(n==1) k=0; if(n==2) k=1; if(n>2) { if(n%2==0) k=0; else { for(i=3;i<=sqrt(n);i+=2) if(n%i==0) { k=0; break; } if(i>sqrt(n)) k=1; } } return k; } int main() { int n,i,j,b[1240]={0},t=0; int sum=0,k=0; for(i=1;i<10050;i++) { if(jud(i)==1) { b[t]=i; t=t+1; } } while(1) { scanf("%d",&n); if(n==0) break; for(j=0;j<=n;j++) { for(i=j;i<=n;i++) { sum+=b[i]; if(sum==n) { k++; break; } if(sum>n) break; } sum=0; } printf("%d\n",k); k=0; } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator