| ||||||||||
| 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>
#include<math.h>
int main()
{
long int m,k,i;
long int a[1000000]={0,0,1,0};
for(m=3;m<1000000;m=m+2)
{
k=sqrt(m);
for(i=2;i<=k;i++)
if(m%i==0)
break;
if(i>=k+1)
a[m]=1;
}
while(1)
{
long int c,d,num;
long int count=0;
long int re;
scanf("%ld%ld%ld",&c,&d,&num);
if(c==0&&d==0&&num==0)
break;
for(re=c;count<num;re+=d)
{
if(a[re]==1)
{
count+=1;
}
}
printf("%ld\n",re-d);
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator