1134 -- 区间质数统计
来源:互联网 发布:sql查询去除重复项 编辑:程序博客网 时间:2024/05/17 03:37
区间质数统计
Time Limit:1000MS Memory Limit:65536K
Total Submit:293 Accepted:200
Description
你的任务是找出[a,b]区间的所有质数个数
Input
两个整数 a b
Output
区间[a,b]的所有质数个数
Sample Input
1 10
Sample Output
4
Hint
4
Source
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace AK1134 { class Program { static bool prime(int n) { if (n == 1) return false; if (n == 2) return true; for (int i = 2; i * i <= n; i++) if (n % i == 0) return false; return true; } static void Main(string[] args) { string[] s = Console.ReadLine().Split(); int[] a = new int[2]; int n = int.Parse(s[0]), m = int.Parse(s[1]); int count = 0; for (int i = n; i <= m; i++) if (prime(i)) count++; Console.WriteLine(count); } } }
0 0
- 1134 -- 区间质数统计
- 1311:区间质数统计
- 区间质数
- 区间质数
- 素数统计 平移区间筛质数(1e9)
- 质数统计
- Noip201502统计质数
- 数论专题 区间质数数量
- POJ 2689 区间筛选质数
- 洛谷 p1865 区间质数个数
- 打印指定区间内的回文质数
- CF 237C (质数区间)
- 【SPOJ-PRIME1】Prime Generator【区间质数筛】
- 打印某一区间的素数(质数)
- 区间统计应用实例
- 分区间统计
- poj 2777 区间统计
- mysql 区间分组统计
- poj 3070 Fibonacci
- DirectX3D游戏开发六 场景光照的实现
- 1133 -- 最近平方数
- Android Fragment 和 Activity
- 刷一题Leetcode:Factorial Trailing Zeroes
- 1134 -- 区间质数统计
- Activit(一)——综述
- COCOS2dx 3.5 实现带白色边框圆形头像功能
- 关于双向链表的建立
- oracle的update更新
- 1135 -- 逆转字符串
- Effective C++ Item1
- 程序设计基石与实践之实现数字七段显示与发扑克牌问题
- STL