submission_id string | problem_id string | status string | code string | input string | output string | problem_description string |
|---|---|---|---|---|---|---|
s153085059 | p00009 | Accepted | import sys
f = [1, 0, 0, 0, 1, 0] * (1000000 // 6 + 1)
f = [0, 0, 1, 1] + f[3:-2]
i = 5
while i < 1000:
if f[i] == 1:
j = i * i
while j <= 1000000:
f[j] = 0
j += i + i
i += 2
for n in sys.stdin:
i = int(n)
print(sum(f[:i + 1])) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s977018189 | p00009 | Accepted | import sys
d = {}
for i in range(2, 1000000):
if i in d:
continue
j = i * i
while j < 1000000:
d[j]=1
j+=i
while True:
n = sys.stdin.readline()
if not n: break
n = int(n.rstrip())
count=0
for i in range(2, n+1):
if not i in d:
count+=1
print count | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s855445569 | p00009 | Accepted | #init
max_num = 1000000
is_prime_num = [True for i in range (max_num+1)]
#0, 1 --- not prime number
is_prime_num[0] = False
is_prime_num[1] = False
end = int(max_num ** .5)
for i in range(2, end+1):
if is_prime_num[i]:
for j in range(i*i, max_num+1, i):
is_prime_num[j] = False
while True:
try:
n = int(input())
prime_cnt = 0
for i in range(1, n+1):
if is_prime_num[i]:
prime_cnt = prime_cnt + 1
print(str(prime_cnt))
except:
break
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s890927931 | p00009 | Accepted | import sys
prime = [2,3,5,7,11,13,17,19,23,29,31]
shieve1 = [1]*1001
for i in prime:
itr = i-1
while(itr<1000):
shieve1[itr] = 0
itr += i
for i in range(32,1000):
if shieve1[i]:
prime.append(i+1)
shieve2 = [1]*(10**6+1)
for i in prime:
itr = i-1
while(itr<10**6):
shieve2[itr] = 0
itr += i
for i in range(1001,10**6+1):
if shieve2[i]:
prime.append(i+1)
for line in sys.stdin:
n = int(line)
cont = 0
for i in prime:
if i<=n:
cont += 1
else:
break
print(cont) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s990087181 | p00009 | Accepted | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
LIMIT = 1000000
is_prime = [True] * (LIMIT+1)
p = 2
while p**2 <= LIMIT:
if is_prime[p]:
for i in range(p*2, LIMIT+1, p):
is_prime[i] = False
p += 1
for line in sys.stdin.readlines():
n = int(line.strip())
if n <= 1:
print(0)
continue
if n == 2:
print(1)
continue
num_prime = 1
for i in range(3, n+1):
if is_prime[i]:
num_prime += 1
print(num_prime) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s097858858 | p00009 | Accepted | import sys
import math as mas
def sieve(n):
p=[True for i in range(n+1)]
p[0]=p[1]=False
end=int(n**0.5)
for i in range(2,end+1):
if p[i]:
for j in range(i*i,n+1,i):
p[j]=False
return p
sosu=sieve(1000010)
for i in sys.stdin:
print(sum(sosu[t] for t in range(int(i)+1)))
# a,b=map(int,i.split())
# print(gcd(a,b),lcm(a,b)) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s268377793 | p00009 | Accepted | import sys
import math as mas
def sieve(n):
p=[True for i in range(n+1)]
p[0]=p[1]=False
end=int(n**0.5)
for i in range(2,end+1):
if p[i]:
for j in range(i*i,n+1,i):
p[j]=False
return p
sosu=sieve(1000010)
for i in sys.stdin:
t=int(i)
if t<2:print(0)
elif t==2:print(1)
else:print(1+sum(sosu[t] for t in range(3,int(i)+1,2)))
# a,b=map(int,i.split())
# print(gcd(a,b),lcm(a,b)) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s217558260 | p00009 | Accepted | primes = [0, 0] + [1]*999999
for i in range(2, 1001):
if primes[i]:
for j in range(i*i, 1000001, i):
primes[j] = 0
while True:
try:
n = int(input()) + 1
print(sum([1 for i in range(n) if primes[i]]))
except:
break | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s488116996 | p00009 | Accepted | list = 1000000 *[1]
list[0] = 0
list[1] = 0
for i in range(1,1000000):
if list[i] == 1:
for j in range(i*i,1000000,i):
list[j] = 0
for i in range(2,1000000):
list[i] += list[i-1]
while True:
try:
n = int(input())
print int(list[n])
except EOFError:
break | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s456734448 | p00009 | Accepted | from math import sqrt,floor
from sys import stdin
def cntPrime(n):
mx = sqrt(n)
if n % 2 == 0:
l = [0, 1] + [1, 0] * (int(n/2) - 1)
else:
l = [0, 1] + [1, 0] * (int(n/2) - 1) + [1]
c = 3
while c < mx:
for k in range(c*2, n+1, c):
l[k-1] = 0
c = l[(c+1):].index(1) + c +2
while c % 2 == 0:
c = l[(c+1):].index(1) + c +2
return l
t = cntPrime(1000000)
for n in stdin:
n = int(n)
print(sum(t[:n])) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s451726157 | p00009 | Accepted | import sys
import math
LIMIT = 1000000
p = 2
pList = [True] * (LIMIT + 1)
while p ** 2 <= LIMIT:
if(pList[p]):
for i in range(p * 2, LIMIT + 1 , p):
pList[i] = False
p += 1
# print(pList)
lines = str(sys.stdin.read()).strip().split("\n")
for line in lines:
line = int(line)
count = 0
for i in range(2, line + 1):
if pList[i]:
count += 1
print(count) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s668654133 | p00009 | Accepted | import sys
def prime(maximum):
sieve = [True] * (maximum + 1)
def sieved(prime):
for not_prime in range(prime + prime, len(sieve), prime):
sieve[not_prime] = False
sieve[0] = sieve[1] = False
sieved(2)
for x in range(3, int(maximum ** 0.5) + 1, 2):
if sieve[x]: sieved(x)
return [prime for prime, is_prime in enumerate(sieve) if is_prime]
count = 0
numbers = []
for line in sys.stdin:
numbers.append(int(line))
count += 1
counts = []
for i in range(count):
counts.append(0)
for prime in prime(1000000):
if prime > 999999:
break
for i in range(count):
if prime <= numbers[i]:
counts[i] += 1
for count in counts:
print(count) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s342056075 | p00009 | Accepted | prime = []
for i in range(0, 1000000):
prime.append(True)
for i in range(0, 1000):
if i < 2:
prime[i] = False
else:
looking = i * 2
while looking < 1000000:
prime[looking] = False
looking += i
sum = []
cnt = 0
for i in range(0, 1000000):
if prime[i]:
cnt += 1
sum.append(cnt)
while True:
try:
n = int(raw_input())
print sum[n]
except:
break | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s086963658 | p00009 | Accepted | import sys
primes = [1] * 500000
primes[0] = 0
for i in range(3, 1000, 2):
if primes[i // 2]:
primes[(i * i) // 2::i] = [0] * len(primes[(i * i) // 2::i])
for i in sys.stdin:
n = int(i)
if n < 4:
print(n - 1)
else:
print(sum(primes[:(n + 1) // 2]) + 1) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s573443569 | p00009 | Accepted | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
import math
N = 1000000
TABLE = [True] * N
def sieve():
TABLE[1] = False
sqrtn = int(math.sqrt(N))
for i in range(2, sqrtn+1):
if TABLE[i]:
for j in range(2*i, N, i):
TABLE[j] = False
"""
for i in range(4, N, 2):
TABLE[i] = False
for i in range(6, N, 3):
TABLE[i] = False
for i in range(6, N, 6):
p1 = 6*i - 1
p2 = 6*i + 1
if p1 >= N: break
if TABLE[p1]:
for j in range(2*p1, N, p1):
TABLE[j] = False
if p2 >= N: break
if TABLE[p2]:
for j in range(2*p2, N, p2):
TABLE[j] = False
"""
def main():
sieve()
for line in sys.stdin:
n = int(line)
cnt = sum(map(lambda k: TABLE[k], range(1, n+1)))
print(cnt)
if __name__ == "__main__": main() | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s851666071 | p00009 | Accepted | def main():
import sys
from math import sqrt
MAX = 1000000
table = [True]*1000000
table[0] = table[1] = False
primes = []
counted = 0
for i in range(MAX):
if table[i]:
primes.append(i)
for j in range(2*i, MAX, i):
table[j] = False
for line in sys.stdin:
n = int(line)
cnt = 0
for prime in primes:
if prime > n:
break
else:
cnt += 1
print(cnt)
if __name__ == '__main__':
main() | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s299677280 | p00009 | Accepted | def main():
import sys
MAX = 1000000
table = [True]*1000000
table[0] = table[1] = False
primes = []
counted = 0
for i in range(MAX):
if table[i]:
primes.append(i)
for j in range(2*i, MAX, i):
table[j] = False
for line in sys.stdin:
n = int(line)
cnt = 0
for prime in primes:
if prime > n:
break
else:
cnt += 1
print(cnt)
if __name__ == '__main__':
main() | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s830504892 | p00009 | Accepted | primes = [0, 0] + [1]*999999
for i in range(2, 1001):
if primes[i]:
for j in range(i*i, 1000001, i):
primes[j] = 0
while True:
try:
data = int(input())
except:
break
print(sum(1 for i in range(data, 1, -1) if primes[i])) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s420441874 | p00009 | Accepted | import sys
def sieve(n):
N = n + 1
ints = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(N)]
try:
ints[0] = ints[1] = False
ints[2] = ints[3] = ints[5] = True
except IndexError:
pass
sqrt = N ** 0.5
for i in range(3, N, 2):
if i >= sqrt:
break
for m in range(i ** 2, N, i):
ints[m] = False
return ints
prime1m = sieve(1000000)
for line in sys.stdin:
print(prime1m[:int(line) + 1].count(True)) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s473465441 | p00009 | Accepted | import sys
from array import array
N = 1000000
primes = array('I',[1]) * (N//2)
primes[0] = 0
for i in range(3,int(N**0.5),2):
if primes[i//2]:
primes[(i*i)//2::i] = array('I',[0]) * len(primes[(i*i)//2::i])
for i in sys.stdin:
n = int(i)
if n < 4:
print(n-1)
else:
print(sum(primes[:(n+1)//2])+1) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s845066908 | p00009 | Accepted | str1=[0 for i in range(10**6)]
str1[0]=1
str1[1]=1
for i in range(2,(10**6)):
if str1[i]==0:
for j in range(2,(10**6)):
if i*j>=len(str1):
break
else:
str1[i*j]=1
while 1 :
try:
x=int(input())
count=0
for i in range(1,x+1):
if str1[i]==0:
count+=1
print(count)
except EOFError:
break | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s862542423 | p00009 | Accepted | # Aizu Problem 0009: Prime Number
#
import sys, math, os, bisect
# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
sys.stdin = open("sample-input.txt", "rt")
def primes2(n):
""" Input n>=6, Returns a list of primes, 2 <= p < n """
n, correction = n-n%6+6, 2-(n%6>1)
sieve = [True] * (n//3)
for i in range(1,int(n**0.5)//3+1):
if sieve[i]:
k=3*i+1|1
sieve[ k*k//3 ::2*k] = [False] * ((n//6-k*k//6-1)//k+1)
sieve[k*(k-2*(i&1)+4)//3::2*k] = [False] * ((n//6-k*(k-2*(i&1)+4)//6-1)//k+1)
return [2,3] + [3*i+1|1 for i in range(1,n//3-correction) if sieve[i]]
primes = primes2(10**6)
for line in sys.stdin:
n = int(line)
idx = bisect.bisect_right(primes, n)
print(idx) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s517636853 | p00009 | Accepted | import bisect
import sys
n = 1000000
primes = {i for i in range(3, n, 2)}
for i in range(3, 1000, 2):
s = {j for j in range(i*2, n, i)}
primes -= s
primes = [2] + sorted(primes)
for l in sys.stdin:
print(bisect.bisect(primes, int(l))) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s316758459 | p00009 | Accepted | import sys
import math
from bisect import bisect_right
n = 1000000
a = set(range(3, n, 2))
diff = a.difference_update
for i in range(3, int(math.sqrt(n)), 2):
if i in a:
diff(range(i*2, n+1, i))
primes = [2] + list(a)
for l in map(int, sys.stdin.readlines()):
print(bisect_right(primes, l)) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s969064627 | p00009 | Accepted | import bisect
primes = [0, 0] + [1]*999999
for i in range(2, 1001):
if primes[i]:
for j in range(i*i, 1000001, i):
primes[j] = 0
primes = [i for i, v in enumerate(primes) if v]
while True:
try:
n = int(input())
except:
break
print(len(primes[:bisect.bisect(primes, n)])) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s468317560 | p00009 | Accepted | import bisect
primes = [0, 0] + [1]*999999
for i in range(2, 1001):
if primes[i]:
for j in range(i*i, 1000001, i):
primes[j] = 0
primes = [i for i, v in enumerate(primes) if v]
while True:
try:
n = int(input())
except:
break
print(bisect.bisect(primes, n)) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s177031388 | p00009 | Accepted | import bisect
primes = [0, 0] + [1]*999999
for i in range(2, 1001):
if primes[i]:
for j in range(i*i, 1000001, i):
primes[j] = 0
primes = list(filter(lambda x: x != 0, [(v != 0) * i for i, v in enumerate(primes)]))
while True:
try:
n = int(input())
except:
break
print(bisect.bisect(primes, n)) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s232578042 | p00009 | Accepted | import sys
import math
M = 1000000
B = int(math.sqrt(M)+1)//6+1
N = M//6
N1 = N+1 if M % 6 == 5 else N
N2 = N+1 if M % 6 >= 1 else N
l = [1] * N1
m = [1] * N2
i = 5
ini = 4
for p in range(B):
if l[p] == 1:
l[p+i::i] = [0] * len(l[p+i::i])
m[ini-1::i] = [0] * len(m[ini-1::i])
if m[p] == 1:
m[p+i+2::i+2] = [0] * len(m[p+i+2::i+2])
l[ini+1::i+2] = [0] * len(l[ini+1::i+2])
i += 6
ini += 5
for i in sys.stdin:
n = int(i)
r = n-1 if n < 3 else sum(l[0:(n+1)//6])+sum(m[0:(n-1)//6])+2
print(r) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s153156610 | p00009 | Accepted | import sys
import math
def isPrime(x):
if x == 2:
return True
if x < 2 or x%2 == 0:
return False
for i in range(3,int(math.sqrt(x))+1,2):
if x%i == 0:
return False
return True
if __name__ == '__main__':
a = []
for tmp_line in sys.stdin:
n = (int)(tmp_line)
a.append(n)
primes = []
for x in range(2,max(a)+1):
if isPrime(x):
primes.append(x)
for y in a:
print(len([x for x in primes if x <= y])) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s099348434 | p00009 | Accepted | import sys
#from me.io import dup_file_stdin
N=1000000
primes = [1]*N
primes[0:2]=[0,0,1]
for i in range(2,N):
if primes[i]==1:
j=i+i
while j<=N:
primes[j]=0
j+=i
#@dup_file_stdin
def solve():
for query in map(int,sys.stdin):
print(sum(primes[2:query+1]))
solve() | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s335474946 | p00009 | Accepted | import sys
MAX = 999999
L = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]
def is_prime(n):
if n == 2:return True
if n % 2 == 0:return False
for i in range(3,int(n**0.5)+1,2):
if n % i == 0:return False
return True
def is_prime_2(n):
a = int(n ** 0.5)
for i in L:
if i > a:return True
if n % i == 0:return False
return True
def prime_count(n):
result = 0
if n >= 2:result+=1
for i in range(3,n+1,2):
if is_prime_2(i):result+=1
return result
def prime_list(n):
result = []
if n >= 2:result.append(2)
for i in range(3,n+1,2):
if is_prime(i):result.append(i)
return result
L2 = prime_list(MAX)
def prime_count_2(n):
for i,v in enumerate(L2):
if v > n:return i
return len(L2)
for n in sys.stdin:
print(prime_count_2(int(n))) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s751486986 | p00009 | Accepted | import sys
MAX = 999999
def is_prime(n):
if n == 2:return True
if n % 2 == 0:return False
for i in range(3,int(n**0.5)+1,2):
if n % i == 0:return False
return True
def prime_list(n):
result = []
if n >= 2:result.append(2)
for i in range(3,n+1,2):
if is_prime(i):result.append(i)
return result
L = prime_list(int(MAX**0.5))
def is_prime_2(n):
a = int(n ** 0.5)
for i in L:
if i > a:return True
if n % i == 0:return False
return True
def prime_count(n):
result = 0
if n >= 2:result+=1
for i in range(3,n+1,2):
if is_prime_2(i):result+=1
return result
L2 = prime_list(MAX)
def prime_count_2(n):
for i,v in enumerate(L2):
if v > n:return i
return len(L2)
for n in sys.stdin:
print(prime_count_2(int(n))) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s116067750 | p00009 | Accepted | import sys
import time
MAX = 999999
def is_prime(n):
if n == 2:return True
if n % 2 == 0:return False
for i in range(3,int(n**0.5)+1,2):
if n % i == 0:return False
return True
def prime_list(n):
return ([2] if n > 1 else []) + [i for i in range(3,n+1,2) if is_prime(i)]
L = prime_list(int(MAX**0.5))
def is_prime_2(n):
a = int(n ** 0.5)
for i in L:
if i > a:return True
if n % i == 0:return False
return True
def prime_count(n):
result = 0
if n >= 2:result+=1
for i in range(3,n+1,2):
if is_prime_2(i):result+=1
return result
def prime_list2(n):
return ([2] if n > 1 else []) + [i for i in range(3,n+1,2) if is_prime_2(i)]
L2 = prime_list2(MAX)
def prime_count_2(n):
for i,v in enumerate(L2):
if v > n:return i
return len(L2)
for n in sys.stdin:
print(prime_count_2(int(n))) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s429180672 | p00009 | Accepted | # coding=utf-8
import array
def sieve_of_eratosthenes(end: int) -> array:
# noinspection PyUnusedLocal
is_prime = array.array('B', (True for i in range(end+1)))
is_prime[0] = False
is_prime[1] = False
primes = array.array("L")
for i in range(2, end+1):
if is_prime[i]:
primes.append(i)
for j in range(i * 2, end+1, i):
is_prime[j] = False
return primes
if __name__ == '__main__':
prime_table = sieve_of_eratosthenes(1000000)
while True:
try:
n = int(input())
except EOFError:
break
prime_table_under_n = [x for x in prime_table if x <= n]
print(len(prime_table_under_n)) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s348321832 | p00009 | Accepted | import sys
N = 999999
lis = []
if N >= 2:
lis.append(2)
if N >= 3:
lis.append(3)
if N >= 5:
for i in xrange(5,N+1,2):
for item in lis:
if item > (i**0.5):
lis.append(i)
break
if i % item == 0:
break
else:
lis.append(i)
dp = [0]*999999
for item in lis:
dp[item-1] += 1
for i in xrange(1,999999):
dp[i] += dp[i-1]
for line in sys.stdin:
num = int(line)
print dp[num-1] | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s362702933 | p00009 | Accepted | n = 999999
c = [1 for i in range(n)]
c[0] = 0
i = 2
while i**2 <= n:
j = i*2
while j <= n:
c[j - 1] = 0
j += i
i += 1
while True:
try:
n = int(input())
print(sum(c[:n]))
except:
break | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s109037581 | p00009 | Accepted | n=1000000
pr = [1] * n
pr[0],pr[1]=0,0
for i in xrange(2, int(n**0.5)+1):
if pr[i] == 1:
for j in range(i ** 2, n , i):
pr[j] =0
for k in xrange(3, n):
pr[k] += pr[k-1]
while True:
try:
m = int(raw_input())
print pr[m]
except:
break | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s388474581 | p00009 | Accepted | n=1000000
pr = [1] * n
pr[0],pr[1]=0,0
for i in range(2, int(n**0.5)+1):
if pr[i] == 1:
for j in range(i ** 2, n , i):
pr[j] =0
for k in range(3, n):
pr[k] += pr[k-1]
while True:
try:
m = int(raw_input())
print pr[m]
except:
break | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s938372256 | p00009 | Accepted | import sys
import math
# Sieve of Eratosthenes
N = 999999
searchList = list(range(3, N + 1, 2))
primes = [2]
while True:
top = searchList.pop(0)
primes.append(top)
if top > math.sqrt(N):
break
searchList = [s for s in searchList if s % top != 0]
primes.extend(searchList)
# solve
for line in sys.stdin:
try:
n = int(line)
ans = [i for i in primes if i <= n]
print(len(ans))
except:
break | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s759030210 | p00009 | Accepted | import sys
def is_prime(x):
if(x <= 3 and x > 1):
return 1
elif(x == 5):
return 1
elif(x % 2 == 0 or x < 2):
return 0
a = 3
while(a * a <= x):
if(x % a == 0):
return 0
a += 2
return 1
def generate_prime(x):
list = []
list.append(2)
for i in range(3,x+1,2):
if(is_prime(i) == 1):
list.append(i)
return list
def count_list(x,list):
count = 0
for i in range(0,len(list)):
if(list[i] > x):
break
elif(list[i] <= x):
count += 1
return count
l = []
for input in sys.stdin:
l.append(int(input))
prime = generate_prime(max(l))
for i in range(0,len(l)):
print count_list(l[i],prime)
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s351592258 | p00009 | Accepted | IsPrimes = [True] * 1000002
IsPrimes[0], IsPrimes[1] = False, False
for i in range(2, 1001):
if IsPrimes[i]:
for j in range(i*i, 1000001, i):
IsPrimes[j]= False
cnt = [0] * 1000001
for i in range(1000001):
if IsPrimes[i]:
cnt[i] += 1
for i in range(1, 1000001):
cnt[i] += cnt[i-1]
while True:
try:
n = int(raw_input())
print cnt[n]
except EOFError:
break
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s729914408 | p00009 | Accepted | primes = [0, 0] + [1] * 999999
for i in range(2, 1000):
if primes[i]:
for j in range(i*i, 1000000, i):
primes[j] = 0
while True:
try:
n = int(input())
except:
break
ans = 0
while n > 0:
ans += primes[n]
n -= 1
print(ans)
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s306359879 | p00009 | Accepted | primes = [0, 0] + [1] * 999999
for i in range(2, 1000):
if primes[i]:
for j in range(i*i, 1000000, i):
primes[j] = 0
answer = [0] * 1000000
for i in range(2, 1000000):
answer[i] += primes[i] + answer[i-1]
while True:
try:
n = int(input())
except:
break
print(answer[n])
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s930532876 | p00009 | Accepted | import bisect
primes = [0, 0] + [1] * 999999
for i in range(2, 1000):
if primes[i]:
for j in range(i*i, 1000000, i):
primes[j] = 0
primes = [i for i, v in enumerate(primes) if v]
while True:
try:
n = int(input())
except:
break
print(bisect.bisect(primes, n))
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s852084833 | p00009 | Accepted | def f(n):
table = [False, False] + [True for _ in range(2, n+1)]
p = 2
while p**2 <= n:
if table[p]:
j = p + p
while j <= n:
table[j] = False
j += p
p += 1
return sum(table)
while True:
try:
n = int(input())
except:
break
print(f(n))
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s941515696 | p00009 | Accepted | def get_input():
while True:
try:
yield ''.join(input())
except EOFError:
break
MAX = 1000000
primes = list()
for i in range(MAX):
primes.append(True)
primes[0] = False
primes[1] = False
for i in range(2, MAX):
j = i + i
while j < MAX:
primes[j] = False
j = j + i
N = list(get_input())
for l in range(len(N)):
n = int(N[l])
ans = 0
for i in range(n+1):
if primes[i]:
ans = ans + 1
print(ans)
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s764792713 | p00009 | Accepted | import sys
m=10**6;a=[1]*m;a[0:2]=0,0
for i in range(2,1000):
if a[i]>0:
for j in range(i*2,m,i):a[j]=0
for i in range(m):a[i]+=a[i-1]
for e in sys.stdin:print(a[int(e)])
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s686426638 | p00009 | Accepted | import sys
m=10**6;a=[1]*m;a[0:2]=0,0
for i in range(2,999):
if a[i]>0:
for j in range(i*2,m,i):a[j]=0
for i in range(m):a[i]+=a[i-1]
for e in sys.stdin:print(a[int(e)])
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s043851036 | p00009 | Accepted | import sys
e=list(map(int,sys.stdin))
m=max(e)+1;a=[1]*m;a[0:2]=0,0
for i in range(2,int(m**.5)+1):
if a[i]>0:
for j in range(i*2,m,i):a[j]=0
for i in range(m):a[i]+=a[i-1]
for x in e:print(a[x])
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s017004589 | p00009 | Accepted | import sys
m=10**6;a=[1]*m;a[0:2]=0,0
for i in range(2,999):
if a[i]>0:
for j in range(i*2,m,i):a[j]=0
for e in sys.stdin:print(sum(a[:int(e)+1]))
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s565334782 | p00009 | Accepted | import sys
m=10**6;a=[0,0]+[1]*m
for i in range(2,999):
if a[i]>0:
for j in range(i*2,m,i):a[j]=0
for e in sys.stdin:print(sum(a[:int(e)+1]))
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s151507619 | p00009 | Accepted | import sys
m=10**6;a=[0,0]+[1]*m
for i in range(2,999):
if a[i]:
for j in range(i*2,m,i):a[j]=0
for e in sys.stdin:print(sum(a[:int(e)+1]))
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s409541858 | p00009 | Accepted | import sys
m=10**6;a=[0,0]+[1]*m
for i in range(999):
if a[i]:
for j in range(i*2,m,i):a[j]=0
for e in sys.stdin:print(sum(a[:int(e)+1]))
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s930339920 | p00009 | Accepted | import sys
m=10**6;a=[0,0]+[1]*m
for i in range(999):
if a[i]:a[i*2::i]=[0 for j in a[i*2::i]]
for e in sys.stdin:print(sum(a[:int(e)+1]))
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s759042931 | p00009 | Accepted | import sys
a=[0,0]+[1]*10**6
for i in range(999):
if a[i]:a[i*2::i]=[0 for j in a[i*2::i]]
for e in sys.stdin:print(sum(a[:int(e)+1]))
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s058275591 | p00009 | Accepted | import sys
a=[0,0]+[1]*10**6
for i in range(999):
if a[i]:a[i*2::i]=[0 for j in[0]*len(a[i*2::i])]
for e in sys.stdin:print(sum(a[:int(e)+1]))
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s436573567 | p00009 | Accepted | import sys
a=[0,0]+[1]*10**6
for i in range(999):
if a[i]:a[i*2::i]=[0]*len(a[i*2::i])
for e in sys.stdin:print(sum(a[:int(e)+1]))
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s661519554 | p00009 | Accepted | import sys
a=[0,0,1]+[1,0]*499999
for i in range(3,999,2):
if a[i]:a[i*2::i]=[0]*len(a[i*2::i])
for e in sys.stdin:print(sum(a[:int(e)+1]))
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s022359712 | p00009 | Accepted | import sys
a=[0,0,1]+[1,0]*499999
for i in range(3,999,2):
if a[i]:a[i*i::i]=[0]*len(a[i*i::i])
for e in sys.stdin:print(sum(a[:int(e)+1]))
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s915693409 | p00009 | Accepted | import sys
m=166666;a=[[1]*m for _ in[0]*2]
for i in range(m):
if a[0][i]:
k=6*i+5
a[0][i+k::k]=[0]*len(a[0][i+k::k])
a[1][-2-i+k::k]=[0]*len(a[1][-2-i+k::k])
if a[1][i]:
k=6*i+7
a[0][-2-i+k::k]=[0]*len(a[0][-2-i+k::k])
a[1][i+k::k]=[0]*len(a[1][i+k::k])
for e in map(int,sys.stdin):
print([e-1,sum(a[0][:(e+1)//6])+sum(a[1][:(e-1)//6])+2][e>3])
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s929654846 | p00009 | Accepted | import sys
m=166666;a=[[1]*m for _ in[0]*2]
for i in range(m):
if a[0][i]:
k=6*i+5
a[0][i+k::k]=[0]*len(a[0][i+k::k])
a[1][-2-i+k::k]=[0]*len(a[1][-2-i+k::k])
if a[1][i]:
k=6*i+7
a[0][-2-i+k::k]=[0]*len(a[0][-2-i+k::k])
a[1][i+k::k]=[0]*len(a[1][i+k::k])
for e in map(int,sys.stdin):
print([e-1,sum(a[0][:(e+1)//6]+a[1][:(e-1)//6])+2][e>3])
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s593003529 | p00009 | Accepted | import sys
m=166666;s=[1]*m;t=[1]*m
for i in range(m):
if s[i]:
k=6*i+5
s[i+k::k]=[0]*len(s[i+k::k])
t[-2-i+k::k]=[0]*len(t[-2-i+k::k])
if t[i]:
k=6*i+7
s[-2-i+k::k]=[0]*len(s[-2-i+k::k])
t[i+k::k]=[0]*len(t[i+k::k])
for e in map(int,sys.stdin):
print([e-1,sum(s[:(e+1)//6])+sum(t[:(e-1)//6])+2][e>3])
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s526991852 | p00009 | Accepted | import sys
m=166666;s=[1]*m;t=[1]*m
for i in range(m):
if s[i]:
k=6*i+5
s[i+k::k]=[0]*len(s[i+k::k])
t[-2-i+k::k]=[0]*len(t[-2-i+k::k])
if t[i]:
k=6*i+7
s[-2-i+k::k]=[0]*len(s[-2-i+k::k])
t[i+k::k]=[0]*len(t[i+k::k])
for e in sys.stdin:
e=int(e)
print([e-1,sum(s[:(e+1)//6])+sum(t[:(e-1)//6])+2][e>3])
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s733389954 | p00009 | Accepted | import sys
m=166666;s=[1]*m;t=[1]*m
for i in range(m):
if s[i]:
k=6*i+5
s[i+k::k]=[0]*len(s[i+k::k])
t[-2-i+k::k]=[0]*len(t[-2-i+k::k])
if t[i]:
k=6*i+7
s[-2-i+k::k]=[0]*len(s[-2-i+k::k])
t[i+k::k]=[0]*len(t[i+k::k])
for e in map(int,sys.stdin):
print((e-1,sum(s[:(e+1)//6])+sum(t[:(e-1)//6])+2)[e>3])
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s478699510 | p00009 | Accepted | import sys
m=166666;s=[1]*m;t=[1]*m
for i in range(m):
for j in range(2):
if (s[i],t[i])[j]:
k=6*i+[5,7][j];n=[i+k,k-i-2]
s[n[j]::k]=[0]*len(s[n[j]::k])
t[n[1-j]::k]=[0]*len(t[n[1-j]::k])
for e in map(int,sys.stdin):
print([e-1,sum(s[:(e+1)//6])+sum(t[:(e-1)//6])+2][e>3])
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s933645032 | p00009 | Accepted | import sys
a=[1]*500000
for i in range(3,999,2):
if a[i//2]:a[(i*i)//2::i]=[0]*len(a[(i*i)//2::i])
for e in map(int,sys.stdin):print([e-1,sum(a[:(e+1)//2])][e>3])
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s810998351 | p00009 | Accepted | import sys
a=[True]*500000
for i in range(3,999,2):
if a[i//2]:a[(i*i)//2::i]=[False]*len(a[(i*i)//2::i])
for e in map(int,sys.stdin):print([e-1,sum(a[:(e+1)//2])][e>3])
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s155450424 | p00009 | Accepted | import sys
a=[1]*500000
for i in range(3,999,2):
if a[i//2]:a[(i*i)//2::i]=[0]*len(a[(i*i)//2::i])
[print([e-1,sum(a[:(e+1)//2])][e>3])for e in map(int,sys.stdin)]
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s799828645 | p00009 | Accepted | import sys
m=500000;a=[1]*m
for i in range(3,999,2):
if a[i//2]:a[i*i//2::i]=[0]*((m-1-i*i//2)//i+1)
for e in map(int,sys.stdin):print([e-1,sum(a[:(e+1)//2])][e>3])
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s958589367 | p00009 | Accepted | import sys
a=[1]*500000
for i in range(3,999,2):
if a[i//2]:a[i*i//2::i]=[0]*len(a[i*i//2::i])
for e in map(int,sys.stdin):print([e-1,sum(a[:(e+1)//2])][e>3])
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s463747905 | p00009 | Accepted | import sys
a=[1]*500000
for i in range(3,999,2):
if a[i//2]:a[i*i//2::i]=[0]*((499999-i*i//2)//i+1)
for e in map(int,sys.stdin):print([e-1,sum(a[:(e+1)//2])][e>3])
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s450870744 | p00009 | Accepted | import sys
m=500000;a=[1]*m
for i in range(3,999,2):
if a[i//2]:a[i*i//2::i]=[0]*len(a[i*i//2::i])
p=[]
for i in range(m*2):p.append(i-1 if i<4 else p[i-1]+[0,a[i//2]][i%2])
for e in sys.stdin:print(p[int(e)])
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s694884622 | p00009 | Accepted | import sys
m=500000;a=[1]*m
for i in range(3,999,2):
if a[i//2]:a[i*i//2::i]=[0]*len(a[i*i//2::i])
p=[]
for i in range(m*2):p+=[i-1 if i<4 else p[i-1]+[0,a[i//2]][i%2]]
for e in sys.stdin:print(p[int(e)])
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s715573057 | p00009 | Accepted | # -*- coding: utf-8 -*-
from math import sqrt
from bisect import bisect
def inpl(): return tuple(map(int, input().split()))
def primes(N):
P = [2]
searched = [False]*(N+1)
for i in range(3, N+1, 2):
if searched[i]:
continue
P.append(i)
for j in range(i, N+1, i):
searched[j] = True
return P
P = primes(10**6)
try:
while True:
print(bisect(P, int(input())))
except:
pass
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s997677111 | p00009 | Accepted | lst = [1 for i in range(10 ** 6 + 1)]
lst[0] = lst[1] = 0
for i in range(10 ** 6 + 1):
if lst[i] == 1:
for j in range(i * 2, 10 ** 6 + 1, i):
lst[j] = 0
while 0 == 0:
try:
n = int(input())
c = 0
for i in range(n + 1):
c += lst[i]
print(c)
except EOFError:
break
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s357396066 | p00009 | Accepted | def make_prime():
prime=[0 for i in range(10**6)]
used=[0 for i in range(10**6)]
for i in range(2,10**6):
if used[i]==1:
prime[i]=prime[i-1]
continue
prime[i]=prime[i-1]+1;
for j in range(i,10**6,i):
used[j]=1
return prime
def main():
prime=make_prime()
while True:
try: n=int(input())
except EOFError: break
print(prime[n])
if __name__=="__main__":
main()
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s257783542 | p00009 | Accepted | import math
def Eratos(n):
primes = [2]
num = [2*i+1 for i in range(1,n//2)]
tmp = []
top = 1
while top < math.sqrt(n):
top = num[0]
for i in range(1,len(num)):
if num[i] % top != 0:
tmp.append(num[i])
num = tmp
tmp = []
primes.append(top)
for i in range(len(num)):
primes.append(num[i])
return primes
def list_count(list_a,n):
cont = 0
for i in range(len(list_a)):
if list_a[i] > n:
break
else:
cont += 1
return cont
primes = Eratos(1000000)
while True:
try:
n = int(input())
print(list_count(primes,n))
except EOFError:
break
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s205511232 | p00009 | Accepted | plst = [1 for i in range(1000001)]
slst = [0,0]
plst[0] = plst[1] = 0
count = 0
for i in range(2,1000001):
if plst[i] == 1:
count += 1
for j in range(i * 2,1000001,i):
plst[j] = 0
slst.append(count)
while True:
try:
print(slst[int(input())])
except EOFError:
break
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s561725684 | p00009 | Accepted | plst = [1 for i in range(1000001)]
plst[0] = plst[1] = 0
for i in range(2,1000001):
if plst[i] == 1:
for j in range(i * 2,1000001,i):
plst[j] = 0
while True:
try:
print(sum(plst[:int(input()) + 1]))
except EOFError:
break
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s029182066 | p00009 | Accepted | LIMIT = 10000000
isPrime = [True for _ in range(LIMIT)]
isPrime[0] = isPrime[1] = False
for i in range(2, int(LIMIT ** 0.5)+1):
if isPrime[i]:
for j in range(i * i, LIMIT, i):
isPrime[j] = False
try:
while True:
n = int(input())
count = 0
if n >= 2:
count = 1
for i in range(3, n+1, 2):
if isPrime[i]:
count += 1
print(count)
except EOFError:
pass
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s557554635 | p00009 | Accepted | def prime_judge(n):
if n==1:
return False
elif n==2:
return True
elif n%2==0:
return False
else:
sqrt_num=int(n**0.5)+1
for i in range(3,sqrt_num, 2):
if n%i==0:
return False
return True
prime=[0]
for i in range(1,1000000):
if prime_judge(i):
prime.append(prime[-1]+1)
else:
prime.append(prime[-1])
while 1:
try:
print(prime[int(input())])
except:
break
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s450496243 | p00009 | Accepted | import sys
N=999999
a=[ 1 for i in range(N+1)]
a[0]=0
a[1]=0
for i in range(2, N+1):
for j in range(i*i,N+1,i):
a[j]=0
b=[ 0 for i in range(N+1)]
t=0
for i in range(2,N+1):
t+=a[i]
b[i]=t
for line in sys.stdin:
n=int(line)
print b[n]
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s472483284 | p00009 | Accepted | from math import sqrt
def f(x):
lst = [i for i in range(x + 1)]
flag = [1 for i in range(x + 1)]
flag[0] = flag[1] = 0
for i in lst:
if flag[i] == 0:
continue
else:
for j in range(i*2, x + 1, i):
flag[j] = 0
return flag.count(1)
a = []
while True:
try:
a.append(int(input()))
except EOFError:
break
for x in a:
print(f(x))
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s552730007 | p00009 | Accepted | # coding: utf-8
LIMIT = 999999
prime = [0, 1] + [0 if i % 2 == 0 else 1 for i in range(3, LIMIT + 1)]
for i in range(3, LIMIT + 1):
if prime[i - 1]:
for j in range(i ** 2, LIMIT + 1, i):
prime[j - 1] = 0
while True:
try:
n = int(input())
except EOFError:
break
print(sum(prime[:n]))
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s992921675 | p00009 | Accepted | # coding: utf-8
LIMIT = 999999
prime = [0, 1] + [0 if i % 2 == 0 else 1 for i in range(3, LIMIT + 1)]
for i in range(3, int(LIMIT ** 0.5) + 1):
if prime[i - 1]:
for j in range(i ** 2, LIMIT + 1, i):
prime[j - 1] = 0
while True:
try:
n = int(input())
except EOFError:
break
print(sum(prime[:n]))
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s016586359 | p00009 | Accepted | # AOJ 0009 Prime Number
# Python3 2018.6.9 bal4u
MAX = 1000000
SQRT = 1000 # sqrt(MAX)
prime = [True for i in range(MAX)]
def sieve():
for i in range(2, MAX, 2):
prime[i] = False
for i in range(3, SQRT, 2):
if prime[i] is True:
for j in range(i*i, MAX, i):
prime[j] = False
sieve()
cnt = [0 for i in range(MAX+1)]
cnt[2] = 1
f = 1
for i in range(3, MAX, 2):
if prime[i] is True:
f += 1;
cnt[i] = f
cnt[i+1] = f
while True:
try:
print(cnt[int(input())])
except EOFError:
break
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s046170693 | p00009 | Accepted | # AOJ 0009 Prime Number
# Python3 2018.6.9 bal4u
MAX = 1000000
SQRT = 1000 # sqrt(MAX)
prime = [0] * MAX
def sieve():
for i in range(3, MAX, 2):
prime[i] = 1
for i in range(3, SQRT, 2):
if prime[i] == 1:
for j in range(i*i, MAX, i):
prime[j] = 0
sieve()
cnt = [0] * (MAX+1)
cnt[2] = f = 1
for i in range(3, MAX, 2):
if prime[i]:
f += 1;
cnt[i] = cnt[i+1] = f
while True:
try:
print(cnt[int(input())])
except EOFError:
break
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s349524642 | p00009 | Accepted | def primes(n):
is_prime = [True] * (n + 1)
is_prime[0] = False
is_prime[1] = False
for i in range(2, int(n**0.5) + 1):
if not is_prime[i]:
continue
for j in range(i * 2, n + 1, i):
is_prime[j] = False
return [i for i in range(n + 1) if is_prime[i]]
if __name__ == "__main__":
while True:
try:
n = int(input())
print(len(primes(n)))
except:
break
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s827763545 | p00009 | Accepted | #!/usr/bin/env python
import sys
list=1000000*[1]
list[0] = 0
list[1] = 0
for i in range(1,1000000):
if list[i] == 1:
for j in range(i*i,1000000,i):
list[j] = 0
for i in range(2,1000000):
list[i] += list[i-1]
for line in sys.stdin:
a = int(line)
print list[a] | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s161412016 | p00009 | Accepted | #!/usr/bin/env python
import sys
list=1000000*[1]
list[0] = 0
list[1] = 0
for i in range(1,1000000):
if list[i] == 1:
for j in range(i*i,1000000,i):
list[j] = 0
for line in sys.stdin:
a = int(line)
b = 0
for x in range(1,a+1):
b += list[x]
print b | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s757010037 | p00009 | Accepted |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env python
import sys
list=1000000*[1]
list[0] = 0
list[1] = 0
for i in range(1,1000000):
if list[i] == 1:
for j in range(i*i,1000000,i):
list[j] = 0
for i in range(2,1000000):
list[i] += list[i-1]
for line in sys.stdin:
a = int(line)
print list[a] | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s806682496 | p00009 | Accepted | # -*- coding: utf-8 -*-
list = [1]*1000000
list[0] = 0
list[1] = 0
for i in range(1, 1000000):
if list[i] == 1:
for j in range(i**2, 1000000, i):
list[j] = 0
for i in range(2, 1000000):
list[i] += list[i -1]
while True:
try:
n = int(raw_input())
print(list[n])
except EOFError:
break | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s703201864 | p00009 | Accepted | import sys
list = [1]*1000000
list[0]=0
list[1]=0
for i in range(1,1000000):
if list[i]==1:
for j in range(i**2, 1000000, i):
list[j]=0
for i in range(2, 1000000):
list[i]+=list[i-1]
for l in sys.stdin:
print list[int(l)] | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s004881555 | p00009 | Accepted | import sys
n=10**6
s=[True]*n
s[0]=False
s[1]=False
for x in xrange(2, int(n**0.5)+1):
if s[x]:
for i in xrange(x+x,n,x):
s[i]=False
for x in sys.stdin.readlines():
x=int(x)+1
cnt=0
for i in xrange(x):
if s[i]:
cnt=cnt+1
print cnt | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s719083059 | p00009 | Accepted | n = 10**6
c = 0
ps = [False]*(n+1)
for i in xrange(2, n+1):
if i%2 != 0 or i == 2:
ps[i] = True
for i in xrange(2, int(n**0.5+1)):
if ps[i]:
for j in xrange(i**2, n+1, i):
ps[j] = False
while 1:
try:
n = input()
if n == 2: print 1
else: print len([0 for i in xrange(2, n+1) if ps[i]])
except EOFError:
break | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s615653991 | p00009 | Accepted | N = 10 ** 6
sieve = map(lambda x:False, range(2, N + 1))
for i in range(2, N + 1):
if sieve[i - 2]:
continue
for j in range(i * 2, N + 1, i):
sieve[j - 2] = True
while True:
try:
n = int(raw_input())
except EOFError:
break
print sieve[:n - 1].count(False) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s340414121 | p00009 | Accepted | def sieve(n):
a = [1] * (n + 1)
for i in range(2, n):
if i * i > n: break
if a[i]:
for j in range(2 * i, n + 1, i):
a[j] = 0
return a[2:]
while True:
try:
n = int(raw_input())
print len(filter(lambda x: x, sieve(n)))
except (EOFError):
break | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s096902962 | p00009 | Accepted | from __future__ import (division, absolute_import, print_function,
unicode_literals)
from sys import stdin
def enum_prime(n):
if n < 2:
return []
if n == 2:
return [2]
L = list(range(2, n + 1))
PL = []
while True:
PL.append(L[0])
L = [i for i in L if i % PL[-1] != 0]
if L[-1] < PL[-1] ** 2:
return PL + L
primelist = enum_prime(999999)
for line in stdin:
n = int(line)
cnt = 0
for p in primelist:
if n < p:
break
cnt += 1
print(cnt) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s891622412 | p00009 | Accepted | '''
Created on Mar 11, 2013
@author: wukc
'''
import sys
N=999999+1
prime=[True for i in range(N)]
cnt=[0 for i in range(N)]
prime[0:2]=[False,False]
for i in range(2,N):
cnt[i]=cnt[i-1]
if prime[i]:
cnt[i]+=1
for j in range(2*i,N,i): prime[j]=False
for l in sys.stdin:
n=int(l)
print cnt[n]
#print prime | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s213489132 | p00009 | Accepted | import sys
n=1000000
pr=[1]*n
pr[0],pr[1]=0,0
for i in range(2,int(n**0.5)+1):
if pr[i]==1:
for j in range(i**2,n,i):
pr[j]=0
for i in range(2,n):
pr[i]+=pr[i-1]
for line in sys.stdin:
print pr[int(line)] | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. 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 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.