HDU 2161 Primes
来源:互联网 发布:纯js分页代码 编辑:程序博客网 时间:2024/05/21 13:22
刷专题,从水题刷起……
水题不能一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 16016int 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;}
阅读全文
0 0
- HDU 2161 Primes 数论
- hdu 2161 Primes
- hdu-2161-Primes
- hdu 2161 Primes
- Primes HDU 2161
- hdu 2161 Primes
- hdu 2161 Primes
- [HDU 2161] Primes
- hdu 2161 Primes
- hdu 2161 Primes(素数)
- HDU 2161 Primes
- HDU 2161 Primes 判断素数
- HDU 2161 Primes 判断素数
- HDU - 2161 - Primes (质数)
- HDU 2161 Primes
- HDU 2161 Primes(素数打表)
- hdu 2161 Primes 筛法求素数 大水题
- hdu 2161 Primes 素数打表
- PHP多进程之很简单很粗暴,shell配合PHP在CLI模式解决程序阻塞等待
- linux初学者-firewall篇
- sdp分辨率设置
- k-means聚类算法与局部最优解
- Android keytool 不是内部或外部命令
- HDU 2161 Primes
- java面向对象四大特性之二 继承,封装
- 无需数学背景,读懂ResNet、Inception和Xception三大变革性架构
- 对于RTTI机制的理解
- [USACO15DEC]最大流Max Flow
- CentOS 6.9 yum方式快速安装MongoDB3.4
- NIPS-2013:Playing Atari with Deep Reinforcement Learning
- java中单例模式的实现
- 备忘录模式与访问者模式