Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

WTF!!!居然暴力都可以过,WA了几次,居然是因为循环的句式选错了,不该用do while

Posted by xijunlee93 at 2013-03-01 20:24:07 on Problem 3006
贴代码
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator