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

各位大神帮忙看下哪里错了,自己运行结果没错

Posted by cai65 at 2012-09-20 23:36:40 on Problem 2739
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator