刷专题,从水题刷起……
水题不能一Y也真是……
1和2,在这题里输出no,其他素数输出yes。注意别用while(1),反正我OLE了一发……
#include<map>
#include<set>
#include<list>
#include<stack>
#include<deque>
#include<queue>
#include<vector>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<math.h>
#include<ctype.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
#include<functional>
#define CPY(A,B)memcpy(A,B,sizeof(A))
#define fin freopen("in.txt","r",stdin)
#define fout freopen("out.txt","w",stdout)
typedef long long LL;
typedef unsigned long long uLL;
const int MOD=1e9+7;
const int INF=0x3f3f3f3f;
const LL INFF=0x3f3f3f3f3f3f3f3fLL;
const double OO=1e20;
const double EPS=1e-9;
const double PI=acos (-1.0);
int dx[]= {0,1,0,-1};
int dy[]= {1,0,-1,0};
using namespace std;
int gcd (const LL &a,const LL &b) {
return b==0?a:gcd (b,a%b);
}
inline int dcmp (double a,double b) {
if (fabs (a-b) <EPS) { return 0; }
return a>b;
}
const int M=16016;
#define MAXN 16016
#define MAXL 16016
int prime[MAXN];
int check[MAXL];
void Init() {
int tot = 0;
memset (check, 0, sizeof (check) );
for (int i = 2; i < MAXL; ++i) {
if (!check[i]) {
prime[tot++] = i;
}
for (int j = 0; j < tot; ++j) {
if (i * prime[j] > MAXL) {
break;
}
check[i*prime[j]] = 1;
if (i % prime[j] == 0) {
break;
}
}
}
}
int main() {
Init();
int cas=0,n;
prime[0]=3;//first is 2, so change it to 3
while (cin>>n) {
if (n<=0) break;
for (int i=0; i<M; ++i) {
if (n<prime[i]) {
printf ("%d: no\n",++cas);break;
} else if (n==prime[i]) {
printf ("%d: yes\n",++cas);break;
}
}
}
return 0;
}