How many prime numbers

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 14686    Accepted Submission(s): 5093

Problem Description
  Give you a lot of positive integers, just to find out how many prime numbers there are.
 
Input
  There are a lot of cases. In each case, there is an integer N representing the number of integers to find. Each integer won’t exceed 32-bit signed integer, and each of them won’t be less than 2.
 
Output
  For each case, print the number of prime numbers you have found out.
 
Sample Input
3
2 3 4
 
Sample Output
2
 
Author
wangye
 
Source
HDU 2007-11 Programming Contest_WarmUp

#include<cstdio>
#include<cmath>
#include<string.h>
#include<algorithm>
using namespace std;
long long s,ans;
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
ans=0;
int flog=1,i;
for(int j=0;j<n;j++)
{
scanf("%lld",&s);
for(i=2,flog=1;flog&&i<=sqrt(s);i++)
if(s%i==0)
flog=0;
if(flog)
ans++;
}
printf("%d\n",ans);
}
return 0;
}

 

hdoj--2138--How many prime numbers(暴力模拟)的更多相关文章

  1. HDOJ(HDU) 2138 How many prime numbers(素数-快速筛选没用上、)

    Problem Description Give you a lot of positive integers, just to find out how many prime numbers the ...

  2. HDU 2138 How many prime numbers(Miller_Rabin法判断素数 【*模板】 用到了快速幂算法 )

    How many prime numbers Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/O ...

  3. 【HDU】2138 How many prime numbers

    http://acm.hdu.edu.cn/showproblem.php?pid=2138 题意:给n个数判断有几个素数.(每个数<=2^32) #include <cstdio> ...

  4. HDU 2138 How many prime numbers

    米勒罗宾素数测试: /* if n < 1,373,653, it is enough to test a = 2 and 3. if n < 9,080,191, it is enoug ...

  5. HDU 2138 How many prime numbers (判素数,米勒拉宾算法)

    题意:给定一个数,判断是不是素数. 析:由于数太多,并且太大了,所以以前的方法都不适合,要用米勒拉宾算法. 代码如下: #include <iostream> #include <c ...

  6. POJ 2739 Sum of Consecutive Prime Numbers( *【素数存表】+暴力枚举 )

    Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 19895 ...

  7. Alexandra and Prime Numbers(思维)

    Alexandra and Prime Numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (J ...

  8. How many prime numbers(求素数个数)

    How many prime numbers Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/O ...

  9. UESTC 1272 Final Pan's prime numbers(乱搞)

    题目链接 Description Final Pan likes prime numbers very much. One day, he want to find the super prime n ...

随机推荐

  1. C#-逆变 协变 反射 代码

    首先看一段测试代码,自己写的 class Program { static void Main(string[] args) { man OneMan = new man(); var d = One ...

  2. COGS——T 438. 烦人的幻灯片

    http://www.cogs.pro/cogs/problem/problem.php?pid=438 ★☆   输入文件:slides.in   输出文件:slides.out   简单对比时间限 ...

  3. lua简单类的实现

    原文地址:http://blog.csdn.net/qqmcy/article/details/37725177 类实现: MyClass = class("MyClass") - ...

  4. 小记 SqlHelper

    using System;using System.Collections.Generic;using System.Data;using System.Linq;using System.Web;u ...

  5. Mysql 数据迁移后 启动出错

    今天上班后不知道为什么,mysql一直无法启动,折腾了半天于是决定重装 我本地的server用的是wamp , 重装的时候, 要进行数据备份 , 我使用的最简单粗暴的备份方式, 就是直接进入到mysq ...

  6. (插播)关于使用jenkins + unity +Xcode 来进行自己主动打包的处理。

    近期了解了下jenkins流程化服务的东西,个人感觉jenkins是一个非常方便的工具.主要是方便.设置好流程性得命令.仅仅需确定下就能够达到自己主动化. 减轻了错误得发生和简化了带来的复杂得步骤.今 ...

  7. scanf使用与运算符

    scanf接收输入 #include <stdio.h> #include <stdlib.h> // 接收用户输入的小写字母,输出大写字母 int main() { char ...

  8. 3.多线程传参,以及tuple数组

    #include <Windows.h> #include <thread> #include <iostream> #include <tuple> ...

  9. xBIM 基础06 将STEP物理文件转换为XML

    系列目录    [已更新最新开发文章,点击查看详细]  一.STEP标准简介 STEP,它是Standard for the Exchange of Product model data的缩写.产品数 ...

  10. Kettle的四大不同环境工具

    不多说,直接上干货! kettle里有不同工具,分别用于ETL的不同阶段. 初学者,建议送Spoon开始.高手,是四大工具都会用. Sqoop: 图形界面工具,快速设计和维护复杂的ETL工作流.集成开 ...