#include<iostream>
#include<cstring>///memset
#define top 1000001
using namespace std;
bool isPrime[top];
void getIsPrime(){
memset(isPrime,true,top);//按字节初始化
isPrime[0]=isPrime[1]=false;
for(int i=2;i<top;++i){
if(isPrime[i]==true){
for(int j=i*2;j<top;j+=i){
isPrime[j]=false;
}
}
}
}
int main(){
getIsPrime();
int a,d,n,ai;
while(cin>>a>>d>>n,a&&d&&n){
for(ai=a;;ai+=d){
if(isPrime[ai]==true) --n;
if(!n) break;
}
cout<<ai<<endl;
}
return 0;
}
POJ 3006 素数
猜你喜欢
转载自blog.csdn.net/Chailyn_Trista/article/details/81004665
今日推荐
周排行