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 |
用C提交才过了#include<stdio.h> #include<math.h> int judge(int n) {int i; for(i=2;i<=(int)(sqrt(n));i++) if(n%i==0) return 0; return 1;} int main() {int n,i,j,sum,count; while(scanf("%d",&n)&&n!=0) {count=0; for(i=2;i<=n;i++) {if(!judge(i)) continue; sum=0; if(i==n) {count+=1; break;} for(j=i;j<=n;j++) {if(!judge(j)) continue; if(sum<n) sum+=j; if(sum==n) {count+=1; break;} if(sum>n) break;} } printf("%d\n",count);} return 0;} Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator