/*
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的更多相关文章

  1. [LeetCode] Count Primes 质数的个数

    Description: Count the number of prime numbers less than a non-negative number, n click to show more ...

  2. 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 ...

  3. leetcode-Count Primes 以及python的小特性

    题目大家都非常熟悉,求小于n的所有素数的个数. 自己写的python 代码老是通不过时间门槛,无奈去看了看大家写的code.下面是我看到的投票最高的code: class Solution: # @p ...

  4. Count Primes - LeetCode

    examination questions Description: Count the number of prime numbers less than a non-negative number ...

  5. [leetcode] Count Primes

    Count Primes Description: Count the number of prime numbers less than a non-negative number, n click ...

  6. Count Primes

    Count the number of prime numbers less than a non-negative number, n public int countPrimes(int n) { ...

  7. 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 ...

  8. HDU 4715:Difference Between Primes

    Difference Between Primes Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Jav ...

  9. hdu 4715 Difference Between Primes

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4715 Difference Between Primes Description All you kn ...

随机推荐

  1. 【C语言】编写函数,将一个数的指定位置置0或置1

    //编写函数,将一个数的指定位置置0或置1 #include <stdio.h> unsigned int set_bit(unsigned int num, int pos, int f ...

  2. ACdream 1154 Lowbit Sum (数位DP)

    Lowbit Sum Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) SubmitSt ...

  3. contest hunter5105 Cookies

    神题 先按贪婪值大到小排序,根据贪心的思想g[i]越大a[i]也越大(这个微扰可以证,给个提示,a>b且c<d 则 (a-b)(c-d)<0 则 ac+bd<ad+bc) DP ...

  4. Solr.NET快速入门(四)【相似查询,拼写检查】

    相似查询 此功能会返回原始查询结果中返回的每个文档的类似文档列表. 参数通过QueryOptions的MoreLikeThis属性定义. 示例:搜索"apache",为结果中的每个 ...

  5. Tomcatsession共享方案--memcached-session-manager

    https://github.com/magro/memcached-session-manager/wiki/SerializationStrategies     MSM的特性:    a.支持t ...

  6. angular中ng-bind指令小案例

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  7. 11.javaweb国际化标签库

    一.国际化标签库 1,格式化标签库提供的标签 2,标签详解 2.1<fmt:setLocale>标签 下面设置不同的区域,并在设置的区域下显示日期 2.2<fmt:requestEn ...

  8. XML文件操作之dom4j

    能够操作xml的api还是挺多的,DOM也是可以的,不过在此记录下dom4j的使用,感觉确实挺方便的 所需jar包官网地址:http://www.dom4j.org/dom4j-1.6.1/ dom4 ...

  9. (转)基于MVC4+EasyUI的Web开发框架形成之旅--基类控制器CRUD的操作

    http://www.cnblogs.com/wuhuacong/p/3352016.html 在上一篇随笔中,我对Web开发框架的总体界面进行了介绍,其中并提到了我的<Web开发框架>的 ...

  10. 原生sql的各种问题

    1.nutz有方法自动根据数据库建models吗?2.select * from a a没有建相应的models怎么取结果?3.可以直接操作result,而不是在callback里面设置吗? wend ...