//其实就是不停的判断素数,网上有些人是先打了个素数表,要注意对1的判断!!!
#include <iostream>
#include <cmath>
using namespace std;
int a,d,n;
int count;
bool is_prime(long x)
{
if(x==1) //千万注意
{
return false;
}
for(int i=2;i*i<=x;i++)
{
if((x!=0)&&(x%i==0))
{
return false;
}
}
return true;
}
int main()
{
while(cin>>a>>d>>n,(a+d+n))
{
count=0;
long x=a;
while(count!=n)
{
if(is_prime(x)==true)
{
count++;
}
x=x+d;
}
if(a=1&&d==1&&n==1)
cout<<2<<endl;
else
{
cout<<x-d<<endl;
}
}
return 0;
}
poj3006
最新推荐文章于 2021-10-14 15:18:09 发布