Skip to content

Instantly share code, notes, and snippets.

@lackofdream
Created April 22, 2015 08:08
Show Gist options
  • Select an option

  • Save lackofdream/20176fd1e727902da0ff to your computer and use it in GitHub Desktop.

Select an option

Save lackofdream/20176fd1e727902da0ff to your computer and use it in GitHub Desktop.
HDU2161
#include <cstdio>
#include <ctime>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <vector>
#include <fstream>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#define MAX(a,b) (a>b?a:b)
#define sd(x) scanf("%d",&x)
#define sdd(a,b) scanf("%d%d",&a,&b)
#define sddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define slflf(x,y) scanf("%lf%lf",&x,&y)
#define abs(x) (x<0?(-x):x)
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
using namespace std;
bool notPrime[20000];
void init()
{
memset(notPrime,0,sizeof(notPrime));
notPrime[0]=1;
notPrime[1]=1;
for (int i=2;i<20000;i++)
{
if (!notPrime[i])
{
for (int j=i+i;j<20000;j+=i) notPrime[j]=1;
}
}
notPrime[2]=1;
}
int main()
{
init();
int n,tcase=0;
while(~sd(n) && n>0)
{
if (notPrime[n])
{
cout << ++tcase << ": no" << endl;
}
else cout << ++tcase << ": yes" << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment