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

用C提交才过了

Posted by 851330 at 2010-12-18 16:00:48 on Problem 2739
#include<stdio.h>
#include<math.h>
int judge(int n)
{int i;
	for(i=2;i<=(int)(sqrt(n));i++)
	if(n%i==0)
	  return 0;
	return 1;}
int main()
{int n,i,j,sum,count;
	while(scanf("%d",&n)&&n!=0)
	    {count=0;
		for(i=2;i<=n;i++)
	    {if(!judge(i))
		    continue;
		    sum=0;
		if(i==n)
		{count+=1;
		 break;}
		 for(j=i;j<=n;j++)
           {if(!judge(j))
			 continue;
			 if(sum<n)
			 sum+=j;		
		      if(sum==n)
			 {count+=1;
			   break;}
			 if(sum>n)
			   break;}
			   }
			   printf("%d\n",count);}
	        return 0;}
	 
	 
	 
	 
	 


	 

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