HDU-2138 How many prime numbers
来源:互联网 发布:vb控件适应窗体大小 编辑:程序博客网 时间:2024/06/05 11:22
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
简单的求素数个数题 :
#include <iostream>#include <cstdlib>#include <cstdio>#include <cmath>#include <iomanip>#include <string>#include <set>#include <map>#include <queue> #include <stack>#include <vector>#include <algorithm>#include <sstream> #include <cstring>using namespace std;bool judge(int x){ for(int i=2;i<=sqrt(x);i++) { if(x%i==0) return true; } return false;} int main(){ int n,t; while(cin>>n) { int ans=0; while(n--) { cin>>t; if( judge(t)==false ) ans++; } cout<<ans<<endl; } return 0;}
阅读全文
0 0
- HDU-2138 How many prime numbers
- hdu 2138 How many prime numbers(miller_rabin?)
- HDU 2138 How many prime numbers
- HDU 2138 How many prime numbers
- hdu 2138 How many prime numbers
- hdu 2138 How many prime numbers
- hdu-2138-How many prime numbers
- hdu-2138- How many prime numbers
- HDU 2138 How many prime numbers
- hdu 2138 How many prime numbers
- HDU 题目2138 How many prime numbers
- HDU 2138 How many prime numbers
- HDU 2138 How many prime numbers
- 水题HDU 2138 How many prime numbers
- hdu 2138 How many prime numbers
- HDU 2138 How many prime numbers
- HDU ACM 2138 How many prime numbers
- hdu-2138 How many prime numbers
- BZOJ 3875: [Ahoi2014&Jsoi2014]骑士游戏 dp spfa
- GDI+ BitMap save 保存图像
- 【NOI2005】瑰丽华尔兹
- 2017.10.07【NOIP提高组】模拟赛B组 偷懒的西西 题解
- 顺序栈ADT实现进制转换
- HDU-2138 How many prime numbers
- 前端学习第三弹:利用div+css制作个人简历
- 使用Markdown编辑数学公式(更新中)
- centos7配置环境变量
- python 缺位补齐
- DFS-带重复元素的全排列
- jzoj5399 【NOIP2017提高A组模拟10.7】Confess
- 国庆中秋假期训练
- hive udf开发以及永久注册udf函数