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 |
各位大神帮忙看下哪里错了,自己运行结果没错#include<iostream> #include<algorithm> #include<iomanip> #include<cmath> #include<string> #include<string.h> using namespace std; int a[10005],b[1500]; int main() { int p=0; for(int i=2;i<10002;i++) if(!a[i]) for(int j=i+i;j<10002;j+=i) a[j]=1; for(int i=2;i<10002;i++) if(a[i]==0) b[p++]=i; int sum=0,k=0,n; while(cin>>n) { if(n==0) return 0; k=0; for(int i=0;b[i]<=n&&i<=p;i++) { sum=0; for(int j=i;b[j]<=n&&i<=p;j++) { sum+=b[j]; if(sum==n) { k++; break; } if(sum>n) break; } } cout<<k<<endl; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator