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 |
Re:这题sample的数据挺全了。。In Reply To:这题sample的数据挺全了。。 Posted by:Acsaga at 2006-11-27 20:42:11 可是我的都过了啊 可是还是WA #include <stdio.h> int c[10000000]={0}; main() { int a,d,n,i,j,k; for(i=2;i<=1000000;i++) { if(c[i]==0) { for(j=i*2;j<=1000000;j=j+i) c[j]=1; } } scanf("%d%d%d",&a,&d,&n); while(a!=0 || d!=0 || n!=0) { k=0; j=-1; while(k<n) { j++; if(c[a+j*d]==0) k++; } printf("%d\n",a+j*d); scanf("%d%d%d",&a,&d,&n); } return(0); } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator