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> #include<cmath> using namespace std; int main() { int a,d,n; int p,x,m,i; double prime[212]; while(cin>>a>>d>>n) { if((a==0)&&(d==0)&&(n==0)) break; x=0; if((a==1)&&(d==1)&&(n==1)) cout<<2<<endl; else{ for(m=1;;m++) { p=0; for(i=2;i<=sqrt(double(a+(m-1)*d));i++) { if((a+(m-1)*d)%i==0) p=1; } if(p==0) { prime[x]=a+(m-1)*d; x++; } if(x==n) break; } cout<<prime[n-1]<<endl; } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator