poj3006
来源:互联网 发布:淘宝店家 编辑:程序博客网 时间:2024/05/20 12:51
#include<stdio.h>
int cnt;
bool isprime(int temp)
{
int k,flag=1;
if(temp==2)
return true;
else if(temp==1||temp%2==0)
return false;
else
{
for(k=3;k*k<=temp;k+=2)
if(temp%k==0)
{
flag=0;
break;
}
}
if(flag)
return true;
else
return false;
}
int main()
{
int a,d,n,m;
while(scanf("%d%d%d",&a,&d,&n)&&(a||d||n))
{
cnt=0;
for(m=a;cnt<n;m+=d)
{
if(isprime(m))
{
cnt++;
}
}
printf("%d\n",m-d);
}
return 0;
}
int cnt;
bool isprime(int temp)
{
int k,flag=1;
if(temp==2)
return true;
else if(temp==1||temp%2==0)
return false;
else
{
for(k=3;k*k<=temp;k+=2)
if(temp%k==0)
{
flag=0;
break;
}
}
if(flag)
return true;
else
return false;
}
int main()
{
int a,d,n,m;
while(scanf("%d%d%d",&a,&d,&n)&&(a||d||n))
{
cnt=0;
for(m=a;cnt<n;m+=d)
{
if(isprime(m))
{
cnt++;
}
}
printf("%d\n",m-d);
}
return 0;
}
- poj3006
- poj3006
- poj3006
- poj3006
- poj3006
- POJ3006
- poj3006
- poj3006
- POJ3006
- POJ3006
- poj3006
- poj3006
- POJ3006
- poj3006
- poj3006
- poj3006 素数
- POJ3006 解题报告
- poj3006(素数筛法)
- parser解析中文问题,xml
- 收藏的资源
- rhel6通过命令关闭防火墙并清除规则
- 诺基亚CEO暗示可能开发Android手机
- [OpenGL ES 03]3D变换:模型,视图,投影与Viewport .
- poj3006
- NSDate的使用
- UI界面类项目 demo
- android基础---HelloWorld(2)
- 理解Android的菜单
- 送别2012
- 感悟生命中的淡泊
- C++共享内存封装类
- hdu1165 Eddy's research II