HDU2161 Primes
/*
HDU2161 Primes
http://acm.hdu.edu.cn/showproblem.php?pid=2161
数论 水题
注意输入截止条件是n<=0
*/
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
//#define test
using namespace std;
const int Nmax=;
int is_prime[Nmax];
void get()
{
for(int i=;i<Nmax;i++)
is_prime[i]=;
for(int i=;i<Nmax;i++)
{
if(is_prime[i])
{
for(int j=;j*i<Nmax;j++)
is_prime[i*j]=;
}
}
is_prime[]=;
}
int main()
{
#ifdef test
#endif
int n,t=;
get();
while(scanf("%d",&n)==)
{
if(n<=)
break;
t++;
printf("%d: ",t);
if(is_prime[n])
printf("yes\n");
else
printf("no\n");
} return ;
}
HDU2161 Primes的更多相关文章
- [LeetCode] Count Primes 质数的个数
Description: Count the number of prime numbers less than a non-negative number, n click to show more ...
- projecteuler Summation of primes
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two milli ...
- leetcode-Count Primes 以及python的小特性
题目大家都非常熟悉,求小于n的所有素数的个数. 自己写的python 代码老是通不过时间门槛,无奈去看了看大家写的code.下面是我看到的投票最高的code: class Solution: # @p ...
- Count Primes - LeetCode
examination questions Description: Count the number of prime numbers less than a non-negative number ...
- [leetcode] Count Primes
Count Primes Description: Count the number of prime numbers less than a non-negative number, n click ...
- Count Primes
Count the number of prime numbers less than a non-negative number, n public int countPrimes(int n) { ...
- hduoj 4715 Difference Between Primes 2013 ACM/ICPC Asia Regional Online —— Warmup
http://acm.hdu.edu.cn/showproblem.php?pid=4715 Difference Between Primes Time Limit: 2000/1000 MS (J ...
- HDU 4715:Difference Between Primes
Difference Between Primes Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Jav ...
- hdu 4715 Difference Between Primes
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4715 Difference Between Primes Description All you kn ...
随机推荐
- Android软键盘状态的切换及其强制隐藏
MainActivity例如以下: package cc.c; import android.os.Bundle; import android.view.View; import android.v ...
- atitit.浏览器插件解决方式----ftp插件 attilax 总结
atitit.浏览器插件解决方式----ftp插件 attilax 总结 1. 界面概览 D:云盘同步目录p5p5f tp.demo.html1 2. 初始化1 3. 事实调用2 4. 參考2 1 ...
- swift+moya URLCahe
1.定义获取缓存策略的接口 import Foundation protocol CachePolicyGettable { var cachePolicy: URLRequest.CachePoli ...
- hdu 1002(大数)
A + B Problem II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- poj1028--动态规划--Ignatius and the Princess III
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
- B1965 [Ahoi2005]SHUFFLE 洗牌 数论
这个题的规律很好找,就是奇数直接除二,偶数除二加n/2.把这个规律整理一下就是(x * 2) % (n + 1),然后就直接求逆元就行了.一直30分的原因是qpow函数传参的时候用的int,然而变量是 ...
- mod_wsgi 初体验
1, 安装 ./configure --with-apxs=/usr/local/apache2/bin/apxs --with-python=/usr/bin/python3 make && ...
- Irrlicht 1.8.4 + Win7 + VC2015 + x64 +OpenGL编译
1. 下载irrlicht1.8.4 https://nchc.dl.sourceforge.net/project/irrlicht/Irrlicht%20SDK/1.8/1.8.4/irrlich ...
- VM-安装MAC系统
搜了下论坛没有这个教程,继续搬运一波,这次教的是用VM15安装Mac OS10.14懒人版VMware安装Windows和Linux比较类似,相对于今天要安装的MAC OS来说过程也比较简单.官方原版 ...
- LeetCode Weekly Contest 20
1. 520. Detect Capital 题目描述的很清楚,直接写,注意:字符串长度为1的时候,大写和小写都是满足要求的,剩下的情况单独判断.还有:我感觉自己写的代码很丑,判断条件比较多,需要改进 ...