hdoj--2138--How many prime numbers(暴力模拟)
2024-10-01 14:08:57
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
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;
}
最新文章
- 像黑客一样使用 Linux 命令行
- mac机快捷键操作
- vs2012 安装entity framework
- CallBack实践。
- c中的关键字、标识符、注释
- 【BZOJ 2648】SJY摆棋子 &; 【BZOJ 2716】【Violet 3】天使玩偶
- VNC server grey screen under ubuntu 14.04
- 【Filter 页面重定向循环】写一个过滤器造成的页面重定向循环的问题
- 敏捷开发系列之旅 第二站(走近XP极限编程)
- tar解压去除文件夹
- 实用的透明背景mark图标
- mysql 5.7忘记密码处理
- Jenkins实现简单的CI功能
- tongweb安装后无法启动问题
- virtualbox装个 ubuntu
- springboot 通过 tomcat 部署的配置
- .NET日志记录之——log4net划重点篇
- IntelliJ IDEA2018.1、2017.3破解教程
- linux 常用 掌握要点 详细终结
- Win32进程创建、进程快照、进程终止用例
热门文章
- C#-MSMQ安装及配置
- hdu 4544 湫湫系列故事——消灭兔子 优先队列+贪心
- 关于python的hashlib md5的报错处理
- pip安装selenium时提示Unknown or unsupported command &#39;install&#39;
- scikit-learn:3.5. Validation curves: plotting scores to evaluate models
- UVALive 4222 /HDU 2961 Dance 大模拟
- vs2015汉化
- Pharmaceutical的同学们都看过来,关于补码运算的复习相关内容
- 还是bib问题
- 机器学习(十一) 支持向量机 SVM(下)