hdoj--2138--How many prime numbers(暴力模拟)
2015-12-20 17:56
267 查看
How many prime numbers
[align=center]Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 14686 Accepted Submission(s): 5093
[/align]
[align=left]Problem Description[/align]
Give you a lot of positive integers, just to find out how many prime numbers there are.
[align=left]Input[/align]
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.
[align=left]Output[/align]
For each case, print the number of prime numbers you have found out.
[align=left]Sample Input[/align]
3
2 3 4
[align=left]Sample Output[/align]
2
[align=left]Author[/align]
wangye
[align=left]Source[/align]
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; }
相关文章推荐
- objectForKey与valueForKey在NSDictionary中的差异
- Factorial Trailing Zeroes
- hdoj--2138--How many prime numbers(暴力模拟)
- 锂电池电压和容量关系
- [Mysql数据库] mysql数据库使用trigger更新中间表
- 前端开发and设计学习网站
- 【杭电】[2026]首字母变大写
- 库函数atoi()的实现
- 20135317 信息安全系统设计基础期末总结
- 对于游戏服务器的一些思考和研究
- python核心编程-标准类派生-不可变类型
- JS组件系列——基于Bootstrap Ace模板的菜单和Tab页效果分享(你值得拥有)
- Objective-C语言——KVC设计模式
- 全面剖析Smarty缓存机制[三种缓存方式]
- 对OkHttp进行封装,实现了只查询缓存,网络请求失败自动查询本地缓存等功能
- win7下firefox浏览器不能使用
- C语言贪吃蛇Linux版
- 接口和工厂
- java web权限管理
- 深入理解java虚拟机之一window下编译OpenJDK环境搭建