| ||||||||||
| 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<stdio.h>
main()
{
int i,n,a[10000],j=1,k=0,x,count,sum;
a[0]=2;
for(n=3;n<10000;n=n+2)
{
for(i=2;i<n;i++)
if(n%i==0)
break;
if(i>=n)
a[j++]=n;
}
while(1)
{
scanf("%d",&x);
if(x==0)
break;
i=count=0;
while(1)
{
sum=0;
for(k=i;k<x;k++)
{
sum+=a[k];
if(sum>x)
break;
if(sum==x)
count++;
}
i++;
if(i>x)
break;
}
printf("%d\n",count);
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator