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 prime[1000000+9]; void prim() { prime[0]=1; prime[1]=1; int i,j,n,m; for(i=2;i<=1000000;i++) { if(prime[i]==0) { for(j=2;;j++) { if(j*i<=1000000) prime[j*i]=1; else break; } } } } int main() { prim(); int i,j,n,m,l; int a,d; while(~scanf("%d%d%d",&a,&d,&n)) { if(a==0&&d==0&&n==0) break; int cnt=0; for(i=a;;i+=d) { if(prime[i]==0) { cnt++; if(cnt==n) { printf("%d\n",i);break;} } } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator