/*
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. python使用pytest+pytest报告

    需要安装pytest和pytest-html pip3 install -U pytest pip3 install -U pytest-html

  2. 公司须要内部的地图服务,准备自己去开发可是成本太高,如今有没有专门为企业提供GIS地图开发的产品呀?大概价格多少?

    公司须要内部的地图服务,准备自己去开发可是成本太高,如今有没有专门为企业提供GIS地图开发的产品呀?大概价格多少?

  3. oc3--类方法1

    // // main.m // 第一个OC类-方法 #import <Foundation/Foundation.h> /* C语言中函数分为声明和实现,OC中定义类, 就是在写类的声明和 ...

  4. eclipse中的.project 和 .classpath文件的具体作用

    .project是项目文件,项目的结构都在其中定义,比如lib的位置,src的位置,classes的位置 .classpath的位置定义了你这个项目在编译时所使用的$CLASSPATH 这些文件你用文 ...

  5. 深度学习利器:TensorFlow在智能终端中的应用——智能边缘计算,云端生成模型给移动端下载,然后用该模型进行预测

    前言 深度学习在图像处理.语音识别.自然语言处理领域的应用取得了巨大成功,但是它通常在功能强大的服务器端进行运算.如果智能手机通过网络远程连接服务器,也可以利用深度学习技术,但这样可能会很慢,而且只有 ...

  6. [SCOI 2003] 字符串折叠

    [题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=1090 [算法] 区间DP [代码] #include<bits/stdc++. ...

  7. POJ 1703 带权并查集

    直接解释输入了: 第一行cases. 然后是n和m代表有n个人,m个操作 给你两个空的集合 每个操作后面跟着俩数 D操作是说这俩数不在一个集合里. A操作问这俩数什么关系 不能确定:输出Not sur ...

  8. [Luogu1273] 有线电视网

    [Luogu1273] 有线电视网 题目描述 某收费有线电视网计划转播一场重要的足球比赛.他们的转播网和用户终端构成一棵树状结构,这棵树的根结点位于足球比赛的现场,树叶为各个用户终端,其他中转站为该树 ...

  9. C#中的值类型、引用类型,代码告诉你他是什么类型。

    C#代码告诉你这是什么类型. using System; using System.Collections.Generic; using System.Linq; using System.Text; ...

  10. vue-router 原理解析

    “更新视图但不重新请求页面”是前端路由原理的核心之一,