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<vector> #include<algorithm> using namespace std; int main() { bool a[12000]={0}; vector<int>b; int start,num,i,j,n,sum; for(i=3;i<103;i+=2) for(j=3;j*i<12000;j+=2) a[i*j]=1; b.push_back(2); for(i=3;i<12000;i+=2) if(!a[i]) b.push_back(i); scanf_s("%d",&n); while(n) { num=0; for(start=0;b[start]<=n;start++) { sum=0; i=start; while(sum<n) sum+=b[i++]; if(sum==n) num++; } printf("%d\n",num); scanf_s("%d",&n); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator