| ||||||||||
| 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<iostream>
int main()
{
int k=1,i,j,a[10000];
int b,sum=0;//输入b来测试
int c=0;//统计个数
scanf("%d",&b);
a[0]=2;
while(b!=0)
{
for(i=3;i<b+1;i++)
{
for(j=2;j<i;j++)
{
if(i%j==0)
break;
}
if(j==i)
{
a[k]=i;
k++;
}
}
for(j=0;j<=b;j++)
{
for(i=j;sum<b;i++)
{sum=sum+a[i];}
if(sum==b){c++;}
sum=0;
}
printf("%d\n",c);
c=0;
k=1;
scanf("%d",&b);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator