码迷,mamicode.com
首页 > 其他好文 > 详细

hdu2012

时间:2015-05-11 21:25:52      阅读:109      评论:0      收藏:0      [点我收藏+]

标签:

http://acm.hdu.edu.cn/showproblem.php?pid=2012

数组大小算错了。。。。。郁闷-_-

 1 #include<iostream>
 2 #include<stdio.h>
 3 #include<stdlib.h>
 4 #include<string.h>
 5 #include<math.h>
 6 using namespace std;
 7 const int N=2600;
 8 int prime[N];
 9 void isprime()
10 {
11     memset(prime,0,sizeof(prime));
12     prime[0]=1;
13     prime[1]=1;
14     for(int i=2;i<N;i++)
15     {
16         if(!prime[i])
17         {
18             for(int j=i+i;j<N;j+=i)
19             prime[j]=1;
20         }
21     }
22     return ;
23 }
24 
25 int main()
26 {
27     //freopen("in.txt","r",stdin);
28     int x,y;
29     isprime();
30     while(cin>>x>>y)
31     {
32         if(!x&&!y)
33         break;
34         int t;
35         if(x>y)
36         {
37             t=x;
38             x=y;
39             y=t;
40         }
41         int flag=0;
42         for(int i=x;i<=y;i++)
43         {
44             t=i*i+i+41;
45             if(prime[t])
46             {
47                 flag=1;
48                 break;
49             }
50         }
51         if(!flag)
52         cout<<"OK"<<endl;
53         else
54         cout<<"Sorry"<<endl;
55     }
56     return 0;
57 }

 

hdu2012

标签:

原文地址:http://www.cnblogs.com/xuesen1995/p/4495426.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!