submission_id string | problem_id string | status string | code string | input string | output string | problem_description string |
|---|---|---|---|---|---|---|
s284914698 | p00009 | Time Limit Exceeded | import sys
def Primes(n):
if n == 1:
return False
else:
flag = True
for i in range(2,n):
if n%i == 0:
flag = False
break
return flag
def primenum(m):
num = 0
for j in range(1,m+1):
if Primes(j)==True:
num += 1
return num
for N in sys.stdin:
print primenum(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>
|
s130530125 | p00009 | Time Limit Exceeded | # coding: utf-8
# Here your code !
import sys
def Primes(n):
if n == 1:
return False
else:
flag = True
for i in range(2,n):
if n%i == 0:
flag = False
break
return flag
def primenum(m):
num = 0
for j in range(1,m+1):
if Primes(j)==True:
num += 1
return num
for N in sys.stdin:
print primenum(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>
|
s579763844 | p00009 | Time Limit Exceeded | # coding: utf-8
# Here your code !
import sys
import math
def Primes(n):
if n == 1:
return False
else:
flag = True
for i in range(2,int(math.sqrt(n))+1):
if n%i == 0:
flag = False
break
return flag
def primenum(m):
num = 0
for j in range(1,m+1):
if Primes(j)==True:
num += 1
return num
for N in sys.stdin:
print primenum(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>
|
s217316571 | p00009 | Time Limit Exceeded | def get_input():
while True:
try:
yield ''.join(input())
except EOFError:
break
if __name__ == '__main__':
array = list(get_input())
cnt,flag = 0,0
for i in range(len(array)):#?????°????????°????????????
for j in range(2,int(array[i])+1):#1??????????´??????¢??????????´???°??¢?´¢????????????
flag = 0
if j == 2:
flag = 1
for k in range(2,j):
if j % k == 0:
flag = 0
break
flag = 1
if flag == 1:
cnt += 1
print(cnt)
cnt = 0 | 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>
|
s410922820 | p00009 | Time Limit Exceeded | def get_input():
while True:
try:
yield ''.join(input())
except EOFError:
break
if __name__ == '__main__':
array = list(get_input())
cnt,flag = 0,0
for i in range(len(array)):#?????°????????°????????????
for j in range(2,int(array[i])+1):#1??????????´??????¢??????????´???°??¢?´¢????????????
flag = 0
if j == 2:
flag = 1
for k in range(2,j):
if j % k == 0:
flag = 0
break
flag = 1
if flag == 1:
cnt += 1
print(cnt)
cnt = 0
| 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>
|
s295602588 | p00009 | Time Limit Exceeded | import math
import sys
def get_primes(n):
search = list(range(2, n+1))
primes = []
while True:
primes.append(search[0])
for i,x in enumerate(search):
if x % primes[-1] == 0:
del search[i]
if len(search) == 0:
return primes
if search[0] >= math.sqrt(n):
primes.extend(search)
return primes
for line in sys.stdin.readlines():
n = int(line)
if n < 2:
print(0)
else:
print(len(get_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>
|
s500237242 | p00009 | Time Limit Exceeded | import math
import sys
def count_primes(n):
is_prime = [True] * n
is_prime[0] = is_prime[1] = False
up = math.sqrt(n)
primes = [2]
while True:
nxt = None
for i in range(primes[-1] + 1, n + 1):
if i % primes[-1] == 0:
is_prime[i-1] = False
else:
if nxt is None:
nxt = i
if primes[-1] >= up:
cnt = 1
for b in is_prime:
if b is True:
cnt +=1
return cnt
primes.append(nxt)
print(count_primes(100))
for line in sys.stdin.readlines():
n = int(line)
if n < 2:
print(0)
else:
print(count_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>
|
s945195080 | p00009 | Time Limit Exceeded | from math import *
search_list = []
search_list_ref = []
prime_list = []
prime_list_ref = []
target1,target2,num = 0,0,2
i,j,k = 0,0,0
flag = 0
def get_input():
while True:
try:
yield ''.join(input())
except EOFError:
break
if __name__ == "__main__":
array = list(get_input())
print("/*------------------------------------*/")
for i in range(len(array)):
print(str(array[i]) + "?????????????´???°????±??????????")
#??\????????¨?????????????????????????????§?´???°????????°?????¢?´¢??????
#?????????sqrt(int(array[i]))?????§????????§?´???°??????????????????
ref_target = int(sqrt(int(array[i])))
search_list_ref.append(2)
search_list_ref.append(ref_target)
while target1 < ref_target:
if search_list_ref == []:
break
prime_list_ref.append(search_list_ref[0])
target1 = search_list_ref[0]
search_list_ref.remove(target1)
if target1 > ref_target:
break
num = target1
if target1 == 2:
for num in range(2,ref_target):
if (num % target1 != 0):
search_list_ref.append(num)
if ref_target != 3:
search_list_ref.remove(ref_target)
else:
for j in search_list_ref:
if j % target1 == 0:
search_list_ref.remove(j)
prime_list_ref = prime_list_ref + search_list_ref
search_list.append(2)
search_list.append(int(array[i]))
#?????????????????¬??\?±????????????°?????????????´???°????±??????????
while target2 < sqrt(int(array[i])):
prime_list.append(search_list[0])
target2 = search_list[0]
search_list.remove(target2)
if target2 > sqrt(int(array[i])):
break
num = target2
if target2 == 2:
for num in range(2,int(array[i])):
for k in prime_list_ref:
if num % k != 0:
flag = 1
else:
flag = 0
break
if flag == 1:
search_list.append(num)
search_list.remove(int(array[i]))
prime_list_ref.pop(0)
search_list[1:1] = prime_list_ref
break
elif target2 not in prime_list_ref:
for j in search_list:
if j % target2 == 0:
search_list.remove(j)
break
else:
pass
prime_list = prime_list + search_list
#print(array[i] + "??\???????´???°????????°???" + str(len(prime_list)))
print(str(len(prime_list)))
del search_list_ref[:]
del prime_list_ref[:]
del search_list[:]
del prime_list[:]
target1 = 0
target2 = 0
print("/*------------------------------------*/") | 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>
|
s100488218 | p00009 | Time Limit Exceeded | from math import *
search_list = []
search_list_ref = []
prime_list = []
prime_list_ref = []
target1,target2,num = 0,0,2
i,j,k = 0,0,0
flag = 0
def get_input():
while True:
try:
yield ''.join(input())
except EOFError:
break
if __name__ == "__main__":
array = list(get_input())
#print("/*------------------------------------*/")
for i in range(len(array)):
#print(str(array[i]) + "?????????????´???°????±??????????")
#??\????????¨?????????????????????????????§?´???°????????°?????¢?´¢??????
#?????????sqrt(int(array[i]))?????§????????§?´???°??????????????????
ref_target = int(sqrt(int(array[i])))
search_list_ref.append(2)
search_list_ref.append(ref_target)
while target1 < ref_target:
if search_list_ref == []:
break
prime_list_ref.append(search_list_ref[0])
target1 = search_list_ref[0]
search_list_ref.remove(target1)
if target1 > ref_target:
break
num = target1
if target1 == 2:
for num in range(2,ref_target):
if (num % target1 != 0):
search_list_ref.append(num)
if ref_target != 3:
search_list_ref.remove(ref_target)
else:
for j in search_list_ref:
if j % target1 == 0:
search_list_ref.remove(j)
prime_list_ref = prime_list_ref + search_list_ref
search_list.append(2)
search_list.append(int(array[i]))
#?????????????????¬??\?±????????????°?????????????´???°????±??????????
while target2 < sqrt(int(array[i])):
prime_list.append(search_list[0])
target2 = search_list[0]
search_list.remove(target2)
if target2 > sqrt(int(array[i])):
break
num = target2
if target2 == 2:
for num in range(2,int(array[i])):
for k in prime_list_ref:
if num % k != 0:
flag = 1
else:
flag = 0
break
if flag == 1:
search_list.append(num)
search_list.remove(int(array[i]))
prime_list_ref.pop(0)
search_list[1:1] = prime_list_ref
elif target2 not in prime_list_ref:
for j in search_list:
if j % target2 == 0:
search_list.remove(j)
else:
pass
prime_list = prime_list + search_list
print(str(len(prime_list)))
del search_list_ref[:]
del prime_list_ref[:]
del search_list[:]
del prime_list[:]
target1 = 0
target2 = 0
#print("/*------------------------------------*/") | 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>
|
s904633520 | p00009 | Time Limit Exceeded | import sys
for line in sys.stdin:
n = int(line)
count = 0
for i in range(2,n+1):
k = 2
flag = True
while k**2 <= i:
if i%k == 0:
flag = False
break
k += 1
if flag:
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>
|
s460375921 | p00009 | Time Limit Exceeded | import sys
for line in sys.stdin:
n = int(line)
arr = [i for i in range(0,n+1)]
k = 2
while k**2 <= n:
for i in range(len(arr)):
if arr[i]%k == 0 and arr[i] != 2:
arr[i] = 0
print(k, arr)
k += 1
count = 0
for i in range(len(arr)):
if arr[i] != 0 and arr[i] != 1:
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>
|
s962244521 | p00009 | Time Limit Exceeded | import sys
import math
def isPrime(n):
if n < 2:
return False
elif n == 2:
return True
if n % 2 == 0:
return False
for i in range(3,math.ceil(math.sqrt(n))+1):
if n % i == 0:
return False
return True
for line in sys.stdin:
n = int(line)
count = 0
for i in range(2,n+1):
if isPrime(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>
|
s184663502 | p00009 | Time Limit Exceeded | import sys
for i in sys.stdin:
n = int(i)
arr = [i for i in range(0,n+1)]
for i in range(2, len(arr)):
if arr[i] != 0:
j = 2
while i*j <= n:
if arr[i*j] != 0:
arr[i*j] = 0
j += 1
primNum = 0
for i in arr:
if i > 1:
primNum += 1
print(primNum) | 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>
|
s886834022 | p00009 | Time Limit Exceeded | o_list=[]
while True:
try:
n=int(input())
I_list=[i for i in range(2,n+1)]
prime_list=[]
for i in I_list:
k=I_list[0]
prime_list.append(k)
for j in I_list:
if j%k==0:
I_list.remove(j)
K=set(I_list) | set(prime_list)
K=list(K)
K=sorted(K)
o_list.append(len(K))
except:
for i in o_list:
print(i)
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>
|
s936393543 | p00009 | Time Limit Exceeded | from math import sqrt
I_list=[]
#input syutoku
while True:
try:
k=int(input())
I_list.append(k)
except:
break
I_max=max(I_list)
#create list (I_max=100 -> [3,5,7,...,99])
odd_list=[x for x in range(3,I_max+1,2)]
#print(W_list)
P_list=[2]
p=0
#print(I_list)
ct=0
while p<=int(sqrt(I_max)):
p=odd_list.pop(0)
P_list.append(p)
P_baisuu=[p*x for x in range(1, int(I_max/p) +1 )]
K_list=set(odd_list)-set(P_baisuu)
odd_list=sorted(list(K_list))
# print("P_list=")
# print(P_list)
# print("odd_list=")
# print(odd_list)
prime_list=P_list+odd_list
#print("prime_list=")
#print(prime_list)
for i in I_list:
w=[j for j in prime_list if j<=i ]
print(len(w)) | 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>
|
s578026368 | p00009 | Time Limit Exceeded | from math import sqrt
I_list=[]
#input syutoku
while True:
try:
k=int(input())
I_list.append(k)
except:
break
I_max=max(I_list)
#create list (I_max=100 -> [3,5,7,...,99])
odd_list=[x for x in range(3,I_max+1,2)]
#print(W_list)
P_list=[2]
p=0
#print(I_list)
ct=0
while p<=int(sqrt(I_max)):
p=odd_list.pop(0)
P_list.append(p)
P_baisuu=[p*x for x in range(1, int(I_max/p) +1 )]
K_list=set(odd_list)-set(P_baisuu)
odd_list=sorted(list(K_list))
# print("P_list=")
# print(P_list)
# print("odd_list=")
# print(odd_list)
prime_list=P_list+odd_list
#print("prime_list=")
#print(prime_list)
for i in I_list:
w=[j for j in prime_list if j<=i ]
print(len(w)) | 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>
|
s793230620 | p00009 | Time Limit Exceeded | p = [0, 0, 1, 1, 0, 1]
while True:
try:
n = int(input())
if len(p) < n+1:
i = len(p)
while i < n+1:
j = 2
flag = True
while j <= i**0.5:
if i % j == 0:
p.append(0)
flag = False
break
j += 1
if flag == True:
p.append(1)
i += 1
print(sum(p[0:n+1]))
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>
|
s893658935 | p00009 | Time Limit Exceeded | import math
def IsPrimer(num):
if num == 1:
isprimer = False
else:
isprimer = True
for divisor in range(2, int(math.sqrt(num)) + 1):
if num % divisor == 0:
isprimer = False
break
return isprimer
while True:
try:
num = eval(input())
count = 0
for i in range(2, num + 1):
if IsPrimer(i):
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>
|
s784148531 | p00009 | Time Limit Exceeded | from math import sqrt
def prime(n):
if n == 2:
return True
elif n < 2 or n % 2 == 0:
return False
else:
i = 3
while i <= sqrt(n):
if n % i == 0:
return False
i += 2
return True
while True:
try:
n = int(input())
if n < 2:
c = 0
else:
c = 1
for i in range(3,n+1,2):
if prime(i):
c += 1
print(c)
except:
exit() | 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>
|
s281831866 | p00009 | Time Limit Exceeded | from math import sqrt
def prime(n):
if n == 2:
return True
elif n < 2 or n % 2 == 0:
return False
else:
i = 1
while p_list[i] <= sqrt(n):
if n % p_list[i] == 0:
return False
i += 1
return True
def p_count(n):
c = 0
for p in p_list:
if(p > n):
break
c += 1
return c
p_list = [2,3]
while True:
try:
n = int(input())
for i in range(p_list[-1]+2,n+1,2):
if (prime(i)):
p_list.append(i)
print(p_count(n))
except:
exit() | 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>
|
s489444592 | p00009 | Time Limit Exceeded | from math import sqrt
n = 1000000
l = [1]*n
c = [0]*n
d = 0
l[1]= l[0] = 0
for i in range(4,n,2):
l[i] = 0
for i in range(9,n,2):
for j in range(3,int(sqrt(i))+1,2):
if i % j == 0:
l[i] = 0
break
for i in range(n):
if l[i] == 1:
d += 1
c[i] = d
while True:
try:
n = int(input())
print(c[n])
except:
exit() | 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>
|
s216371192 | p00009 | Time Limit Exceeded | # ?´???°?????°?????¨?????????????????°??????
import sys
prim_no = {}
def is_prime(no):
if no == 2:
return True
if no % 2 == 0:
return False
if prim_no.get(no) is not None:
return prim_no.get(no)
for i in range(3, no // 2):
if no % i == 0:
prim_no[no] = False
return False
prim_no[no] = True
return True
while True:
num = sys.stdin.readline()
if num is None or num.strip() == '':
break
num = int(num.strip())
cnt = 0
for i in range(2, num + 1):
if is_prime(i):
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>
|
s511230219 | p00009 | Time Limit Exceeded | # ?´???°?????°?????¨?????????????????°??????
import sys
import math
prim_no = {} # ????????°????´???°??§??????????????????????????????
def is_prime(no):
if no == 2:
return True
if no % 2 == 0:
return False
if prim_no.get(no) is not None:
return prim_no.get(no)
max_check = int(math.sqrt(no))
for i in range(3, max_check+1):
if no % i == 0:
prim_no[no] = False
return False
prim_no[no] = True
return True
def main():
while True:
num = sys.stdin.readline()
if num is None or num.strip() == '':
break
num = int(num.strip())
cnt = 0
for i in range(2, num + 1):
if is_prime(i):
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>
|
s156295684 | p00009 | Time Limit Exceeded | # ?´???°?????°?????¨?????????????????°??????
import sys
import math
prim_no = {} # ????????°????´???°??§??????????????????????????????
def is_prime(no):
if no == 2:
return True
if no % 2 == 0:
return False
if prim_no.get(no) is not None:
return prim_no.get(no)
max_check = int(math.sqrt(no))
for i in range(3, max_check+1, 2):
if no % i == 0:
prim_no[no] = False
return False
prim_no[no] = True
return True
def main():
while True:
num = sys.stdin.readline()
if num is None or num.strip() == '':
break
num = int(num.strip())
cnt = 0
for i in range(2, num + 1):
if is_prime(i):
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>
|
s953964361 | p00009 | Time Limit Exceeded | # ?´???°?????°?????¨?????????????????°??????
import sys
import math
prim_no = {2: True} # ????????°????´???°??§??????????????????????????????
def is_prime(no):
if no == 2:
return True
if no % 2 == 0:
return False
if prim_no.get(no) is not None:
return prim_no.get(no)
max_check = int(math.sqrt(no))
for i in range(3, max_check+1, 2):
if no % i == 0:
prim_no[no] = False
return False
prim_no[no] = True
return True
def main():
while True:
num = sys.stdin.readline()
if num is None or num.strip() == '':
break
num = int(num.strip())
if num == 1:
cnt = 0
else:
cnt = 0
for i in range(3, num + 1):
if is_prime(i):
cnt += 1
cnt += 1
print(cnt)
if __name__ == '__main__':
main()
#print(prim_no) | 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>
|
s297186562 | p00009 | Time Limit Exceeded | # ?´???°?????°?????¨?????????????????°??????
import sys
import math
prim_no = {2: True} # ????????°????´???°??§??????????????????????????????
def is_prime(no):
if no == 2:
return True
if no % 2 == 0:
return False
if prim_no.get(no) is not None:
return prim_no.get(no)
max_check = int(math.sqrt(no))
for i in range(3, max_check+1, 2):
if no % i == 0:
prim_no[no] = False
return False
prim_no[no] = True
return True
def main():
while True:
num = sys.stdin.readline()
if num is None or num.strip() == '':
break
num = int(num.strip())
if num == 1:
cnt = 0
else:
cnt = 0
for i in range(3, num + 1, 2):
if is_prime(i):
cnt += 1
cnt += 1
print(cnt)
if __name__ == '__main__':
main()
#print(prim_no) | 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>
|
s446458857 | p00009 | Time Limit Exceeded | # ?´???°?????°?????¨?????????????????°??????
import sys
import math
#prim_no = {2: True} # ????????°????´???°??§??????????????????????????????
def is_prime(no):
if no == 2 or no == 1:
return True
if no % 2 == 0:
return False
# if prim_no.get(no) is not None:
# return prim_no.get(no)
max_check = int(math.sqrt(no))
for i in range(3, max_check+1, 2):
if no % i == 0:
# prim_no[no] = False
return False
# prim_no[no] = True
return True
def main():
prim_vals = {} # ????????°?????§????´???°????????°
num_data = [] # ?????????????????????
while True:
num = sys.stdin.readline()
if num is None or num.strip() == '':
break
num = int(num.strip())
num_data.append(num)
sorted_num_data = sorted(num_data)
prim_num = {}
for num in sorted_num_data:
if prim_vals.get(num) is not None:
cnt = prim_vals.get(num)
else:
if num == 1:
cnt = 0
else:
cnt = 0
if num % 2 == 0:
start_num = num -1
else:
start_num = num
for i in range(start_num, 0, -2):
if prim_vals.get(i) is not None:
cnt += prim_vals.get(i)
break
if is_prime(i):
cnt += 1
prim_vals[num] = cnt # ????????°?????§????´???°????????°????????????
prim_num[num] = cnt
for num in num_data:
print(prim_num[num])
if __name__ == '__main__':
main()
#print(prim_no) | 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>
|
s499498509 | p00009 | Time Limit Exceeded | import sys
import math
a = []
for line in sys.stdin:
a.append(line)
nnum=[2]
for i in a:
num=int(i)
if num==1:
print "0"
elif num==2:
print "1"
elif num==3:
print "2"
else:
time=1
ch=(num-1)/2
for n in range(ch):
n=n*2+3
check=1
for m in nnum:
if n%m==0 and n!=m:
check=0
break
if m**2>n:
break
if check==1:
time+=1
if n not in nnum:
nnum.append(n)
print time | 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>
|
s293452809 | p00009 | Time Limit Exceeded | import sys
import math
a = []
for line in sys.stdin:
a.append(line)
nnum=[2]
for i in a:
num=int(i)
if num==1:
print "0"
elif num==2:
print "1"
elif num==3:
print "2"
elif num<nnum[-1]:
nnum.append(num)
nnum.sort()
time=nnum.index(num)
nnum.remove(num)
print time
elif num==nnum[-1]:
print len(nnum)
else:
add=len(nnum)
time=0
if nnum[-1]==nnum[0]:
d=1
else:
d=nnum[-1]
ch=(num-d)/2
for n in range(ch):
n=n*2+d+2
check=1
for m in nnum:
if n%m==0 and n!=m:
check=0
break
if m**2>n:
break
if check==1:
time+=1
if n not in nnum:
nnum.append(n)
print time+add | 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>
|
s336425082 | p00009 | Time Limit Exceeded | import sys
def isPrime(i):
if i<2:
return False
else:
for i in range(2,n):
if i*i>n:
break
elif n%i==0:
return False
return True
def countPrime(i):
cnt=0
for x in range(2,i+1):
if isPrime(x) == True:
cnt+=1
return cnt
for line in sys.stdin:
n=int(line)
print(countPrime(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>
|
s027404688 | p00009 | Time Limit Exceeded | import random
import sys
def is_prime3(q,k=50):
q = abs(q)
if q == 2: return True
if q < 2 or q&1 == 0: return False
d = (q-1)>>1
while d&1 == 0:
d >>= 1
for i in xrange(k):
a = random.randint(1,q-1)
t = d
y = pow(a,t,q)
while t != q-1 and y != 1 and y != q-1:
y = pow(y,2,q)
t <<= 1
if y != q-1 and t&1 == 0:
return False
return True
a = []
for line in sys.stdin:
a.append(line)
nnum=[2]
for i in a:
num=int(i)
if num==1:
print "0"
elif num==2:
print "1"
elif num==3:
print "2"
elif num<nnum[-1]:
nnum.append(num)
nnum.sort()
time=nnum.index(num)
nnum.remove(num)
print time
elif num==nnum[-1]:
print len(nnum)
else:
add=len(nnum)
time=0
if nnum[-1]==nnum[0]:
d=1
else:
d=nnum[-1]
ch=(num-d)/2
for n in range(ch):
n=n*2+d+2
if is_prime3(n):
time+=1
if n not in nnum:
nnum.append(n)
print time | 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>
|
s345610581 | p00009 | Time Limit Exceeded | import sys
a = []
for line in sys.stdin:
a.append(line)
nnum=[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]
for i in a:
num=int(i)
if i==1:
print "0"
elif i==2:
print "1"
else:
nnum.append(num)
nnum.sort()
time=nnum.index(num)
nnum.remove(num)
print time
num=(num-1)/2
for n in range(num):
n=n*2+3
time+=1
for nn in nnum:
if n%nn==00:
time-=1
break
print time | 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>
|
s369419630 | p00009 | Time Limit Exceeded | import sys
def isPrime(i):
if i<2:
return False
else:
for j in range(2,i):
if j*j>n:
break
elif i%j==0:
return False
return True
def countPrime(i):
cnt=0
for x in range(2,i+1):
if isPrime(x) == True:
print(x)
cnt+=1
return cnt
for line in sys.stdin:
n=int(line)
cnt=0
for x in range(2,n+1):
if isPrime(x)==True:
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>
|
s506038571 | p00009 | Time Limit Exceeded | import sys
def isPrime(i):
if i<2:
return False
else:
for j in range(2,i):
if j*j>n:
break
elif i%j==0:
return False
return True
def countPrime(i):
cnt=0
for x in range(2,i+1):
if isPrime(x) == True:
print(x)
cnt+=1
return cnt
while True:
try:
n=int(input())
cnt=0
for x in range(2,n+1):
if isPrime(x)==True:
cnt+=1
print(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>
|
s351560285 | p00009 | Time Limit Exceeded | import sys
def isPrime(i):
if i<2:
return False
else:
for j in range(2,i):
if j*j>i:
break
elif i%j==0:
return False
return True
def countPrime(i):
cnt=0
for x in range(2,i+1):
if isPrime(x) == True:
print(x)
cnt+=1
return cnt
while True:
try:
n=int(input())
cnt=0
for x in range(2,n+1):
if isPrime(x)==True:
cnt+=1
print(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>
|
s249187955 | p00009 | Time Limit Exceeded | import sys
def is_prime(n, primes):
for prime in primes:
if prime ** 2 > n:
return True
if n % prime == 0:
return False
return True
def count_prime():
primes = [2, 3]
for i in range(5, 999999, 2):
if is_prime(i, primes):
primes.append(i)
return primes
primes = count_prime()
for line in sys.stdin:
n = int(line)
count = 0
for i in range(2, n+1):
if i in primes:
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>
|
s114122883 | p00009 | Time Limit Exceeded | import math
def isprime(num):
for y in range(2, int(math.ceil(math.sqrt(num)))+1):
if num%y==0:
return 0
return 1
while True:
try:
n=input()
count= 1 if n >= 2 else 0
for x in range(3,n+1,2):
count+=isprime(x)
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>
|
s554009909 | p00009 | Time Limit Exceeded | import sys
import math
def isprime(num):
for y in range(2, int(math.ceil(math.sqrt(num)))+1):
if num%y==0:
return 0
return 1
for l in sys.stdin:
n=int(l)
count= 1 if n >= 2 else 0
for x in range(3,n+1,2):
count+=isprime(x)
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>
|
s719646966 | p00009 | Time Limit Exceeded | import sys
import math
dic={}
def isprime(num):
for y in range(3, int(x**0.5)+1,2):
if num%y==0:
dic[num]=0
return 0
dic[num]=1
return 1
for l in sys.stdin:
n=int(l)
count= 1 if n >= 2 else 0
for x in range(3,n+1,2):
count+=dic.get(x, isprime(x))
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>
|
s638355694 | p00009 | Time Limit Exceeded | import math
def isprime(n):
if n==2:
return True
if n<2 or n%2==0:
return False
i=3
while i<=math.sqrt(n):
if n%i==0:
return False
i=i+2
return True
while True:
try:
n=int(input())
L=[i for i in range(n+1) if isprime(i)]
print(len(L))
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>
|
s317986303 | p00009 | Time Limit Exceeded | import math
def isPrime(x):
if x == 2:
return True
elif x < 2 or x % 2 == 0:
return False
else:
i = 3
while i <= math.sqrt(x):
if x % i == 0:
return False
i += 2
return True
import sys
dataset = sys.stdin.readlines()
for n in dataset:
n = int(n)
counter = 0
for i in range(n+1):
if isPrime(i):
counter += 1
print(counter) | 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>
|
s388319040 | p00009 | Time Limit Exceeded | def isprime(num):
if num==1:return False
if num==2:return True
for i in range(int(num/2)):
if num%(i+2)==0:
return False
else:continue
return True
def ct(num):
count=0
for i in range(num):
if isprime(i+1):count+=1
return count
def yak(num):
if isprime(num):return [1,num]
if num==1: return[1]
for i in range(int(num/2)):
if num%(i+2)==0:
ret=yak(i+2)+yak(num/(i+2))
ret.remove(1)
return sorted([int(i) for i in ret])
while True:
try:raw=[int(i) for i in input().split(" ")]
except:break
a=raw[0]
print(str(ct(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>
|
s924484038 | p00009 | Time Limit Exceeded | def ct(num):
primel=[2]
for i in range(num):
n=i+1
if i==0 or i==1:continue
for e in primel:
if n%e==0:break
else:primel.append(n)
return len(primel)
while True:
try:raw=[int(i) for i in input().split(" ")]
except:break
a=raw[0]
print(str(ct(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>
|
s112600254 | p00009 | Time Limit Exceeded | def ct(num):
primel=[2]
for i in range(2,num+1):
for e in primel:
if i%e==0:break
else:primel.append(i)
return len(primel)
while True:
try:raw=[int(i) for i in input().split(" ")]
except:break
a=raw[0]
print(str(ct(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>
|
s468953246 | p00009 | Time Limit Exceeded | def kqpurge(num):
k=0
while num%2==0:
num=num/2
k+=1
return k,int(num)
def miller_l(num):
k,q=kqpurge(num-1)
tnum=0
if num==1:return False
if num in [2,3,5,7]:return True
for i in [2,3,5,7]:
for e in range(k+1):
if e==0:
if i**q%num==1:
tnum+=1
break
elif i**q%num==num-1:
tnum+=1
break
else:
temp=i**((2**e)*q)
if temp%num==(num-1):
tnum=tnum+1
break
elif temp%num==1:
break
if tnum==4:
return True
else:
return False
while True:
try:n=int(input())
except:break
count=0
for i in range(2,n+1):
if miller_l(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>
|
s168327603 | p00009 | Time Limit Exceeded | import math
m=999999
l=[False]*m
l[1]=True
for i in range(3,m+1):
if i%2==0:continue
for e in range(2,int(math.sqrt(i)+1)):
if i%e==0:
break
else:
l[i-1]=True
while True:
try:n=int(input())
except:break
print(len([i for i in l[:n:] if 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>
|
s814167337 | p00009 | Time Limit Exceeded | import math
m=999999
l=[False]*m
l[1]=True
l[2]=True
for i in range(5,m+1):
if i%2==0 or i%3==0:continue
for e in range(2,int(math.sqrt(i)+1)):
if i%e==0:
break
else:
l[i-1]=True
while True:
try:n=int(input())
except:break
print(len([i for i in l[:n:] if 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>
|
s134836453 | p00009 | Time Limit Exceeded | import sys
for line in sys.stdin:
count = 0
n = int(line)
if n>=2: count += 1
for i in range(3,n+1,2):
if pow(2,i-1,i)==1: 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>
|
s712636510 | p00009 | Time Limit Exceeded | def erato(n):
s = list(range(n+1))
s[1] = 0
for e in s:
if e:
for i in range(e*2, n+1, e):
s[i] = 0
return s
while True:
try:
n = int(input())
print(len(list(filter(lambda x:x, erato(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>
|
s089456218 | p00009 | Time Limit Exceeded | import sys
[print(sum([1 if sum([0 if y % z != 0 else 1 for z in range(2, y)]) == 0 else 0 for y in [y + 1 for y in range(2, x)]]) + 1) for x in [int(x) for x in 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>
|
s060300610 | p00009 | Time Limit Exceeded | import sys
def prime(n):
for i in range(2, n):
if n < i ** 2: break
elif n % i == 0: return False
return True
[print(len([i for i in range(2, int(x)) if prime(i)])) for x in 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>
|
s039351377 | p00009 | Time Limit Exceeded | from math import sqrt,floor
def isPrime(x):
if x==1:
return 0
for i in range(2,1+floor(sqrt(x))):
if x%i == 0:return 0
return 1
inputs=[]
while True:
try:
inputs.append(int(input()))
except EOFError:
break
for i in inputs:
a = 0
for j in range(1,i+1):
a+=isPrime(j)
print(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>
|
s040390190 | p00009 | Time Limit Exceeded | from math import sqrt
def eratosthenes(n):
def era(x,p):
if x<=p or (x>p and x%p!=0):
return x
else:
return None
A=[i for i in range(2,n+1)]
p=2
while p<=sqrt(n):
A=list(filter(lambda x:era(x,p),A))
p+=1
return(A)
inputs=[]
while True:
try:
inputs.append(int(input()))
except EOFError:
break
for i in inputs:
print(len(eratosthenes(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>
|
s549674558 | p00009 | Time Limit Exceeded | def era(x,p):
if x<=p or (x>p and x%p!=0):
return x
else:
return None
def eratosthenes(n):
A=[i for i in range(2,n+1)]
p=2
while p<=n**(1/2):
A=list(filter(lambda x:era(x,p),A))
p+=1
return(A)
inputs=[]
while True:
try:
inputs.append(int(input()))
except EOFError:
break
for i in inputs:
print(len(eratosthenes(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>
|
s175229564 | p00009 | Time Limit Exceeded | primes = [2,3,5]
while True:
try:
n = int(input())
except EOFError:
break
if n > primes[-1]:
q = primes[-1]+2
while q <= n:
f = True
for i in primes:
if q%i == 0:
f = False
break
if f:
primes.append(q)
q+=2
print(len(primes))
elif n == primes[-1]:
print(len(primes))
else:
for i,p in enumerate(primes):
if p > n:
print(i+1)
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>
|
s628371507 | p00009 | Time Limit Exceeded | nums = []
while True:
try:
n = int(input())
except EOFError:
break
nums.append(n)
M = max(nums)
primes = []
temp = [i for i in range(2,M+1)]
n = 2
while n*n <= M:
primes.append(n)
for i in temp:
if i%n == 0:
temp.remove(i)
n=temp[0]
primes.extend(temp)
for i in nums:
f = True
for j,n in enumerate(primes):
if n > i:
print(j)
f = False
break
if f:
print(len(primes)) | 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>
|
s690076185 | p00009 | Time Limit Exceeded | while True:
try:
M = int(input())
except EOFError:
break
N = (M+1)//2-1
temp = [i for i in range(1, N+1)]
for j in range(1,(N-1)//3+1):
for i in range(1,j+1):
if i+j+2*i*j>N:
break
try:
temp.remove(i+j+2*i*j)
except ValueError:
pass
print(len(temp)+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>
|
s708711929 | p00009 | Time Limit Exceeded | # -*- coding: utf-8 -*-
import sys
for line in sys.stdin:
input_number = int(line.strip())
if input_number == 1:
print 0
continue
elif input_number == 2:
print 1
continue
prime_numbers = {2: ""}
candidate_number = 3
while candidate_number <= input_number:
flag = True
for number in prime_numbers:
if candidate_number % number == 0:
# print candidate_number, number
flag = False
break
if flag:
prime_numbers[candidate_number] = ""
candidate_number += 2
print len(prime_numbers) | 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>
|
s359112603 | p00009 | Time Limit Exceeded | # -*- coding: utf-8 -*-
import sys
for line in sys.stdin:
input_number = int(line.strip())
if input_number == 1:
print 0
continue
elif input_number == 2:
print 1
continue
prime_numbers = [2]
candidate_number = 3
while candidate_number <= input_number:
flag = True
for index, number in enumerate(prime_numbers):
if candidate_number % number == 0:
flag = False
break
elif number * prime_numbers[index - 1] > input_number and index >= 1:
break
if flag:
prime_numbers.append(candidate_number)
candidate_number += 2
print len(prime_numbers) | 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>
|
s258156893 | p00009 | Time Limit Exceeded | # -*- coding: utf-8 -*-
import sys
import math
for line in sys.stdin:
input_number = int(line.strip())
if input_number == 1:
print 0
continue
elif input_number == 2:
print 1
continue
prime_numbers = [2]
candidate_number = 3
while candidate_number <= input_number:
flag = True
max_number = int(math.sqrt(prime_numbers[-1]))
for number in prime_numbers:
if candidate_number % number == 0:
flag = False
break
elif number > max_number:
break
if flag:
prime_numbers.append(candidate_number)
candidate_number += 2
print len(prime_numbers) | 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>
|
s287027602 | p00009 | Time Limit Exceeded | while True:
try:
Num = 1
n = int(input())
for i in range(2,n+1):
for j in range(2,i):
if i % j == 0:
break
if j == i-1:
Num +=1
print(Num)
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>
|
s293155602 | p00009 | Time Limit Exceeded | DP = [0,1,2]
while True:
try:
n = int(input())
if len(DP) < n:
for i in range(len(DP) + 1,n+1):
YN = 0
for j in range(2,i - 1):
if i % j == 0:
DP.append(DP[len(DP) - 1])
YN = 1
break
elif j ** 2 > i:
DP.append(DP[len(DP) - 1] + 1)
break
print(DP[n - 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>
|
s816666876 | p00009 | Time Limit Exceeded | DP = [0,1,2]
while True:
try:
k = int(input())
n = 1000000
if len(DP) < n:
for i in range(len(DP) + 1,n+1):
YN = 0
for j in range(2,i - 1):
if i % j == 0:
DP.append(DP[len(DP) - 1])
YN = 1
break
elif j ** 2 > i:
DP.append(DP[len(DP) - 1] + 1)
break
print(DP[k - 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>
|
s308833945 | p00009 | Time Limit Exceeded | import sys
values = []
for line in sys.stdin:
if 1000000 > int(line):
values.append(int(line))
for val in values:
prime = 0
i = 2
while i <= val:
j = 2
while j <= i:
if i % j == 0:
if j == i:
prime += 1
else:
break
j += 1
i += 1
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>
|
s107357529 | p00009 | Time Limit Exceeded | import sys
values = []
for line in sys.stdin:
values.append(int(line))
for val in values:
prime = 0
i = 2
while i <= val:
j = 2
while j <= i:
if i % j == 0:
if j == i:
prime += 1
else:
break
j += 1
i += 1
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>
|
s078768893 | p00009 | Time Limit Exceeded | import sys
def Input(sequence):
'''
??\????????????????????§??????????????????
:param sequence: ??????????????????????????????
:return:
'''
for line in sys.stdin:
try:
sequence.append(int(line))
except ValueError:
break
def SearchPrimeNumber(sequence):
'''
??\???????????§????´???°?????????????????¨??????????????????
:param sequence: ??\???????????????
:return:
'''
for val in values:
prime = 0
for i in range(2, val + 1):
for j in range(2, i + 1):
if i % j == 0:
# 1???????????§??????????????????????????´???????´???°
if i == j:
prime += 1
else:
break
print(prime)
if __name__ == '__main__':
values = []
Input(values)
SearchPrimeNumber(values) | 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>
|
s594394462 | p00009 | Time Limit Exceeded | while True:
try:
n = int(input())
count = 0
if n == 1:
print("0")
else:
a = [2*i for i in range(2, 1000000)]
b = [3*i for i in range(2, 1000000)]
c = [5*i for i in range(2, 1000000)]
d = [7*i for i in range(2, 1000000)]
for i in range(2, n+1):
if i not in a and i not in b and i not in c and i not in d:
count += 1
print(count)
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>
|
s630523401 | p00009 | Time Limit Exceeded | import sys
for l in sys.stdin:
s=int(l)
ccc=0
for kusa in range(2,s+1):
bbb=0
for kuso in range(1,s+1):
if kusa%kuso==0:
bbb=bbb+1
if bbb==2:
ccc=ccc+1
print(ccc) | 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>
|
s706559773 | p00009 | Time Limit Exceeded | import sys
for ss in sys.stdin:
s=int(ss)+1
if s<2:
print(0)
else:
list=[True]*s
list[0]=False
list[1]=False
i=2
while i**2<=s-1:
j=i*2
while j<=s-1:
list[j]=False
j+=i
i+=1
print(list.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>
|
s625849185 | p00009 | Time Limit Exceeded | import sys
while True:
try:
s=int(input())+1
except:
sys.exit()
if s<2:
print(0)
else:
list=[True]*s
list[0]=False
list[1]=False
i=2
while i**2<=s-1:
j=i*2
while j<=s-1:
list[j]=False
j+=i
i+=1
print(list.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>
|
s560376957 | p00009 | Time Limit Exceeded | # coding: utf-8
import sys
import math
max = 11
prime = [2,3,5,7,11]
for line in sys.stdin:
n = int(line)
if n > max:
for m in range(max + 1, n + 1):
flag = 1
if m % 2 == 0:
flag = 0
else:
for p in prime:
if p > math.sqrt(m):
break
if m % p == 0:
flag = 0
break
if flag == 1:
prime.append(m)
max = n
count = 0
for i in prime:
if i > n:
break
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>
|
s397771412 | p00009 | Time Limit Exceeded | import sys
def sosu(n):
if n < 2:
return False
else:
for i in range(2,n):
if i * i > n:
break
elif n % i ==0:
return False
return True
if __name__ == '__main__':
for line in sys.stdin:
ko=0
n = int(line)
for i in range(0,n+1):
if sosu(i):
ko+=1
print(ko) | 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>
|
s331273426 | p00009 | Time Limit Exceeded | # -*- coding:utf-8 -*-
import sys
# n??\???????´???°?????°???????????¢??°
def prime(n):
l = range(0,n+1)
i,k = 0,2
result = 1
if n >= 3:
prime_nums = [2, 3]
else:
prime_nums = []
while i <= n:
while l[i] > k:
result = l[i]%k
k = k+1
if result == 0:
break
if (l[i]-1 == k) and (result != 0):
prime_nums.append(l[i])
i, k = i+1, 2
#return prime_nums
return len(prime_nums)
array = []
for i in sys.stdin:
array.append(int(i))
l = len(array)
for i in array:
psum = prime(i)
print(psum)
| 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>
|
s833555946 | p00009 | Time Limit Exceeded | # -*- coding:utf-8 -*-
import sys
# n??\???????´???°?????°???????????¢??°
def prime(n):
l = range(0,n+1)
i,k = 0,2
result = 1
if n >= 3:
prime_nums = [2, 3]
else:
prime_nums = []
while i <= n:
while l[i] > k:
result = l[i]%k
k = k+1
if result == 0:
break
if (l[i]-1 == k) and (result != 0):
prime_nums.append(l[i])
i, k = i+1, 2
#return prime_nums
return len(prime_nums)
array = []
#for i in sys.stdin:
# array.append(int(i))
#l = len(array)
#for i in array:
# psum = prime(i)
# print(psum)
for i in sys.stdin:
psum = prime(int(i))
print(psum) | 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>
|
s662965855 | p00009 | Time Limit Exceeded | # -*- coding:utf-8 -*-
import sys
# n??\???????´???°?????°?????????
def prime(n):
l = range(0,n+1)
i,k = 0,2
result = 1
if n >= 3:
prime_nums = [2, 3]
else:
prime_nums = []
while i <= n:
while l[i] > k:
result = l[i]%k
k = k+1
if result == 0:
break
if (l[i]-1 == k) and (result != 0):
prime_nums.append(l[i])
i, k = i+1, 2
#return prime_nums
return len(prime_nums)
while True:
try:
psum = prime(int(input()))
print(psum)
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>
|
s200949311 | p00009 | Time Limit Exceeded | import sys
def isp(n):
a = 1
for i in range(2, (n + 1) // 2 + 2):
if not n % i:
a = 0
break
return a
for i in sys.stdin:
i = int(i)
if i == 2:
print(1)
elif i == 3:
print(2)
else:
s = 2
for x in range(2, i + 1):
if isp(x):
s += 1
print(s) | 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>
|
s367958646 | p00009 | Time Limit Exceeded | import sys
def isp(n):
a = 1
for i in range(2, (n + 1) // 2 + 2):
if not n % i:
a = 0
break
return a
ary = []
for i in sys.stdin:
ary.append(int(i))
for i in ary:
if i == 2:
print(1)
elif i == 3:
print(2)
else:
s = 2
for x in range(2, i + 1):
if isp(x):
s += 1
print(s) | 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>
|
s414668974 | p00009 | Time Limit Exceeded | import sys
ary=[]
for i in sys.stdin:
ary.append(int(i))
def isp(n):
a = 1
for i in range(2, int(n ** 0.5) + 1):
if not n % i:
a = 0
break
return a
for m in ary:
s = 0
for i in range(2, m+1):
if isp(i):
s += 1
print(s) | 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>
|
s099131628 | p00009 | Time Limit Exceeded | import sys
def prime(x):
for i in p_list:
if x % i == 0:
return 0
return 1
if __name__ == "__main__":
a = 10000
i = 2
p_list = []
while i < a:
if prime(i):
p_list.append(i)
i += 1
print(p_list)
for i in sys.stdin:
n = int(i)
while 1:
if n not in p_list:
n -= 1
else:
print(p_list.index(n) + 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>
|
s077493852 | p00009 | Time Limit Exceeded | from math import sqrt
def isprime(n):
if n == 1:
return 0
if n == 2:
return 1
if n % 2 == 0:
return 0
for i in range(2,int(sqrt(n)+1)):
if n % i == 0:
return 0
return 1
from sys import stdin
for i in stdin:
i = int(i)
print(sum(isprime(n) for n in range(2,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>
|
s434801379 | p00009 | Time Limit Exceeded | from math import sqrt
cash = {}
def isprime(n):
if n in cash:
return cash[n]
if n == 1:
return 0
if n == 2:
return 1
if n % 2 == 0:
return 0
for i in range(2,int(sqrt(n)+1)):
if n % i == 0:
return 0
cash[n] = 1
return 1
from sys import stdin
h = {}
for i in stdin:
i = int(i)
c = sum(isprime(n) for n in range(2,i+1))
print(c) | 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>
|
s214228555 | p00009 | Time Limit Exceeded | from math import sqrt
cash = {}
def isprime(n):
if n in cash:
return cash[n]
if n == 1:
cash[n] = 0
return 0
if n == 2:
cash[n] = 1
return 1
if n % 2 == 0:
cash[n] = 0
return 0
for i in range(2,int(sqrt(n)+1)):
if n % i == 0:
cash[n] = 0
return 0
cash[n] = 1
return 1
from sys import stdin
cash2 = {}
for i in stdin:
i = int(i)
c = sum(isprime(n) for n in range(2,i+1))
print(c) | 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>
|
s785422678 | p00009 | Time Limit Exceeded | from math import sqrt
cash = {}
def isprime(n):
if n in cash:
return cash[n]
if n == 1:
cash[n] = 0
return 0
if n == 2:
cash[n] = 1
return 1
if n % 2 == 0:
cash[n] = 0
return 0
for i in range(3,int(sqrt(n)+1))[0::2]:
if n % i == 0:
cash[n] = 0
return 0
cash[n] = 1
return 1
from sys import stdin
cash2 = {}
for i in stdin:
i = int(i)
c = sum(isprime(n) for n in range(2,i+1))
print(c) | 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>
|
s472335543 | p00009 | Time Limit Exceeded | from math import sqrt
cash = {}
def isprime(n):
if n in cash:
return cash[n]
if n == 1:
cash[n] = 0
return 0
if n == 2:
cash[n] = 1
return 1
if n % 2 == 0:
cash[n] = 0
return 0
for i in range(3,int(sqrt(n)+1))[0::2]:
if n % i == 0:
cash[n] = 0
return 0
cash[n] = 1
return 1
from sys import stdin
#cash2 = {}
for i in stdin:
i = int(i)
c = sum(isprime(n) for n in range(2,i+1)[1::2]) + 1
print(c) | 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>
|
s262101252 | p00009 | Time Limit Exceeded | from math import sqrt
cash = {}
def isprime(n):
if n in cash:
return cash[n]
for i in range(3, int(sqrt(n)+1))[0::2]:
if n % i == 0:
cash[n] = 0
return 0
cash[n] = 1
return 1
from sys import stdin
cash2 = {}
for i in stdin:
i = int(i)
c = sum(isprime(n) for n in range(2, i+1)[1::2]) + 1
print(c) | 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>
|
s026060420 | p00009 | Time Limit Exceeded | from math import sqrt
cash = {}
def isprime(n):
if n in cash:
return cash[n]
for i in range(3, int(sqrt(n)+1))[0::2]:
if n % i == 0:
cash[n] = 0
return 0
cash[n] = 1
return 1
from sys import stdin
for i in stdin:
print(sum(isprime(n) for n in range(2, int(i)+1)[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>
|
s638814286 | p00009 | Time Limit Exceeded | while True:
try:
n = int(input())
prime_cnt = 0
for i in range(2, n+1):
cnt = 0
for j in range(1,i):
if i % j == 0:
cnt = cnt + 1
if cnt == 1:
#?´???°
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>
|
s395150686 | p00009 | Time Limit Exceeded | import math
while True:
try:
n = int(input())
prime_cnt = 0
for i in range(2, n+1):
cnt = 0
for j in range(2,i):
if i % j == 0:
cnt = cnt + 1
break
if cnt == 0:
#?´???°
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>
|
s597594465 | p00009 | Time Limit Exceeded | import math
def is_prime_num(in_num):
cnt = 0
if in_num == 2:
return True
elif in_num <= 1:
return False
elif in_num % 2 == 0:
return False
else:
max_num = int(math.sqrt(in_num))
for j in range(3, in_num, 2):
if in_num % j == 0:
cnt = cnt + 1
break
if cnt == 0:
#?´???°
return True
else:
return False
while True:
try:
n = int(input())
prime_cnt = 0
for i in range(2, 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>
|
s168225984 | p00009 | Time Limit Exceeded | import math
def is_prime_num(in_num):
cnt = 0
if in_num == 2:
return True
elif in_num <= 1:
return False
elif in_num % 2 == 0:
return False
else:
max_num = int(math.sqrt(in_num)+1)
for j in range(3, max_num, 2):
if in_num % j == 0:
cnt = cnt + 1
break
if cnt == 0:
#?´???°
return True
else:
return False
while True:
try:
n = int(input())
prime_cnt = 0
for i in range(2, 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>
|
s558708725 | p00009 | Time Limit Exceeded | # coding: utf-8
# Here your code !
import math
def is_prime_num(in_num):
cnt = 0
if in_num == 2:
return True
elif in_num <= 1:
return False
elif in_num % 2 == 0:
return False
else:
if pow(2, in_num-1, in_num) == 1:
max_num = int(math.sqrt(in_num)+1)
for j in range(3, max_num, 2):
if in_num % j == 0:
cnt = cnt + 1
break
if cnt == 0:
#??´????°
return True
else:
return False
else:
return False
while True:
try:
n = int(input())
prime_cnt = 0
for i in range(2, 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>
|
s452064417 | p00009 | Time Limit Exceeded | # coding: utf-8
# Here your code !
import math
def is_prime_num(in_num):
cnt = 0
if in_num == 2:
return True
elif in_num <= 1:
return False
elif in_num % 2 == 0:
return False
else:
if pow(2, in_num-1, in_num) == 1:
max_num = int(math.sqrt(in_num)+1)
for j in range(3, max_num, 2):
if in_num % j == 0:
cnt = cnt + 1
break
if cnt == 0:
#??´????°
return True
else:
return False
else:
return False
while True:
try:
n = int(input())
prime_cnt = 0
if n >= 2:
#?????????2???????????????
prime_cnt = prime_cnt + 1
for i in range(3, n+1, 2):
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>
|
s843541034 | p00009 | Time Limit Exceeded | # coding: utf-8
# Here your code !
import math
def is_prime_num(in_num):
cnt = 0
if in_num == 2:
return True
elif in_num <= 1:
return False
elif in_num % 2 == 0:
return False
else:
if pow(2, in_num-1, in_num) == 1:
return True
else:
return False
while True:
try:
n = int(input())
prime_cnt = 0
if n >= 2:
#?????????2???????????????
prime_cnt = prime_cnt + 1
for i in range(3, n+1, 2):
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>
|
s320700255 | p00009 | Time Limit Exceeded | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import math
import sys
def atkin(limit):
sqrt_limit = int(math.sqrt(limit))
is_prime = [False] * (limit + 1)
primes = []
if limit == 1:
return primes
if limit >= 2:
is_prime[2] = True
if limit >= 3:
is_prime[3] = True
for x in range(1, sqrt_limit):
for y in range(1, sqrt_limit):
k = 4*x**2 + y**2
if k <= limit and (k%12 == 1 or k%12 == 5):
is_prime[k] ^= True
k = 3*x**2 + y**2
if k <= limit and k%12 == 7:
is_prime[k] ^= True
k = 3*x**2 - y**2
if x > y and k <= limit and k%12 == 11:
is_prime[k] ^= True
r = 5
while r**2 < limit:
if is_prime[r]:
i = r**2
while i < limit:
is_prime[i] = False
i += r**2
r += 1
for i in range(limit + 1):
if is_prime[i]:
primes.append(i)
return primes
for line in sys.stdin.readlines():
n = int(line.strip())
primes = atkin(n)
#print(primes)
print(len(primes)) | 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>
|
s838869273 | p00009 | Time Limit Exceeded | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import math
import sys
def is_prime(x):
if x == 2:
return True
if x < 2 or x%2 == 0:
return False
i = 3
while i <= int(math.sqrt(x)):
if x%i == 0:
return False
i += 2
return True
for line in sys.stdin.readlines():
n = int(line.strip())
num_prime = 0
for x in range(1, n + 1):
if is_prime(x):
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>
|
s790345224 | p00009 | Time Limit Exceeded | import math
import sys
a = [] # create an array to save input integers
for line in sys.stdin:
a.append(int(line))
def is_prime(n):
for i in range(2, int(math.sqrt(n) + 1)):
if n % i == 0:
return False
return True
for i in a:
c = 0
for j in range(2, i + 1):
if is_prime(j):
c += 1
print c | 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>
|
s399302024 | p00009 | Time Limit Exceeded | def PrimeNumber(num,summation):
for i in range(1,num+1):
n=0
for j in range(1,i):
if i%j==0:
n+=1
if n==1:
summation+=1
return summation
while True:
try:
num=int(input())
except:
break
print(PrimeNumber(num,0)) | 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>
|
s540072749 | p00009 | Time Limit Exceeded | while True:
try:
num=int(input())
except:
break
sum=0
for i in range(1,num+1):
n=0
for j in range(1,i):
if i%j==0:
n+=1
if n==1:
sum+=1
print(sum) | 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>
|
s804158100 | p00009 | Time Limit Exceeded | import sys
from itertools import takewhile
primes = [2, 3, 5, 7]
append_prime = primes.append
upper = 10
def is_prime(num):
for p in primes:
if num % p == 0:
return False
return True
def calc_prime(num):
for i in range(upper + 1, num + 1):
if is_prime(i):
append_prime(i)
for s in sys.stdin:
n = int(s)
if upper < n:
calc_prime(n)
upper = n
print(len(primes))
else:
print(len(tuple(takewhile(lambda x: x <= n, primes)))) | 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>
|
s919892821 | p00009 | Time Limit Exceeded | from math import sqrt
from sys import stdin
def isprime(n):
if n == 1:
return False
if n == 2:
return True
if n % 2 == 0:
return False
for i in range(3, int(sqrt(n))+1):
if n % i == 0:
return False
return True
for n in stdin:
n = int(n)
ct = 0
for i in range(1,n + 1):
if isprime(i):
#print (i)
ct += 1
print (ct) | 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.