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;
}

 

最新文章

  1. 像黑客一样使用 Linux 命令行
  2. mac机快捷键操作
  3. vs2012 安装entity framework
  4. CallBack实践。
  5. c中的关键字、标识符、注释
  6. 【BZOJ 2648】SJY摆棋子 &amp; 【BZOJ 2716】【Violet 3】天使玩偶
  7. VNC server grey screen under ubuntu 14.04
  8. 【Filter 页面重定向循环】写一个过滤器造成的页面重定向循环的问题
  9. 敏捷开发系列之旅 第二站(走近XP极限编程)
  10. tar解压去除文件夹
  11. 实用的透明背景mark图标
  12. mysql 5.7忘记密码处理
  13. Jenkins实现简单的CI功能
  14. tongweb安装后无法启动问题
  15. virtualbox装个 ubuntu
  16. springboot 通过 tomcat 部署的配置
  17. .NET日志记录之——log4net划重点篇
  18. IntelliJ IDEA2018.1、2017.3破解教程
  19. linux 常用 掌握要点 详细终结
  20. Win32进程创建、进程快照、进程终止用例

热门文章

  1. C#-MSMQ安装及配置
  2. hdu 4544 湫湫系列故事——消灭兔子 优先队列+贪心
  3. 关于python的hashlib md5的报错处理
  4. pip安装selenium时提示Unknown or unsupported command &#39;install&#39;
  5. scikit-learn:3.5. Validation curves: plotting scores to evaluate models
  6. UVALive 4222 /HDU 2961 Dance 大模拟
  7. vs2015汉化
  8. Pharmaceutical的同学们都看过来,关于补码运算的复习相关内容
  9. 还是bib问题
  10. 机器学习(十一) 支持向量机 SVM(下)