| ||||||||||
| 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 | |||||||||
1A(给打表大仙跪下)#include<iostream>
#include<cmath>
using namespace std;
const int N=10009;
int nP,p[N];
bool isprime(int x) {
if (x<2) return 0;
for (int i=2;i<=(int)sqrt(x);++i)
if (x%i==0) return 0;
return 1;
}
void shuffle() {
for (int i=1;i<=10000;++i)
if (isprime(i)) p[++nP]=i;
}
int main() {
shuffle();
int x;
while (cin>>x) {
if (x==0) return 0;
int ans=0;
for (int l=1;l<=nP;++l) {
int cnt=0,r=l;
for (;r<=nP&&cnt<x;++r)
cnt+=p[r];
if (cnt==x) ++ans;
}
cout<<ans<<endl;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator