View Code
1 /* hit 3014 */
2 #include <iostream>
3 #include <cstring>
4 using namespace std;
5 typedef long long ll;
6 int prime[1000000],tem[1000000],t ;
7 void init()
8 {
9 memset(prime,0,sizeof(prime));
10 for(ll i=2;i<=1000000;i++) // qiu sqrt(10^12) nei su shu
11 {
12 if(!prime[i])
13 {
14 for(ll j=2;j*i<=1000000;j++)
15 {
16 prime[j*i] = 1;
17 }
18 }
19 }
20 t = 0;
21 for(int i=2;i<1000000;i++)
22 {
23 if(!prime[i])
24 {
25 tem[t++] = i;
26 }
27 }
28 }
29 void check(ll n)
30 {
31 for(int i=0;i<t&&tem[i]<n;i++)
32 {
33 if(n%tem[i]==0)
34 {
35 cout<<"No"<<" "<<tem[i]<<endl;
36 return;
37 }
38 }
39 cout<<"Yes"<<endl;
40 }
41 int main()
42 {
43 ll n; // n wei he shu ,na me bi you su yin zi <= sqrt(n)
44 init();
45 while(cin>>n)
46 {
47 check(n);
48 }
49 return 0;
50 }
 posted on 2011-04-24 17:40  eth0  阅读(149)  评论(0编辑  收藏  举报