| ||||||||||
| 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 | |||||||||
WTF!!!居然暴力都可以过,WA了几次,居然是因为循环的句式选错了,不该用do while贴代码
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
long a,d,n,k,p,i;
double temp;
while(1)
{
cin>>a>>d>>n;
if (a==0)
break;
k=0;
while (1)
{
p=1;
if (a==1)
p=0;
temp=sqrt((double)a);
for (i=2;i<=temp;i++)
if (a%i==0)
{p=0;break;}
if (p==1)
k++;
if (k==n)
break;
a+=d;
}
cout<<a<<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