Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## 无赖之下

Posted by cycpp at 2008-07-26 10:23:15 on Problem 2739
In Reply To:好久没打过表了…… Posted by:summery at 2006-08-07 18:39:41
```n从2到10000都输出了真确的结果  但就是RTE!!!

#include <iostream>
#include <math.h>
using namespace std;
int susu(int n)
{
if(n<=3)return 1;
if(n%2==0)return 0;
int middle=(int)sqrt(double(n));
int i;
for(i=3;i<=middle;i+=2)//奇数不能被偶数整除
{
if(n%i==0)break;
}
if(i>middle)return 1;
else return 0;
}
int main()
{
int p[1130]={0};
int i,j;
j=1;
for(i=2;i<10000;i++)if(susu(i)==1)p[j++]=i;
int n;
cin>>n;
while(n)
{
int count=0;
i=1129;
while(n<p[i])i--;
j=i;
int sum=p[i];
while(i!=0)
{

if(sum==n)
{
count++;
sum-=p[j];
j--;
i--;
sum+=p[i];
continue;
}
else	if(sum<n)
{
i--;
sum+=p[i];
}
else
{
sum-=p[j];
j--;
}
}
cout<<count<<endl;
cin>>n;
}
return 0;
}

```

Followed by: