Aizu 0009 Prime Number【统计素数】

原题网址:

http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0009


Prime Number

Time Limit : 1 sec, Memory Limit : 65536 KB 
Japanese version is here

Prime Number

Write a program which reads an integer n and prints the number of prime numbers which are less than or equal to n. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5, 7.

Input

Input consists of several datasets. Each dataset has an integer n (n ≤ 999999) in a line.

The number of datasets ≤ 30.

Output

For each dataset, prints the number of prime numbers.

Sample Input

10
3
11

Output for the Sample Input

4
2
5



题意:

给出n ,输出不大于n的素数有多少个


题解:

打表筛选的时候进行统计

/*
http://blog.csdn.net/liuke19950717
*/
#include
#include
#include
using namespace std;
typedef long long ll;
const int maxn= 999999+5;
ll prime[maxn];
int main()
{
	ll cnt=0;
	for(ll i=2;i


你可能感兴趣的:(其他oj,数论)