submission_id string | problem_id string | status string | code string | input string | output string | problem_description string |
|---|---|---|---|---|---|---|
s515433658 | p00009 | Time Limit Exceeded | from math import sqrt,floor
from sys import stdin
def cntPrime(n):
mx = sqrt(n) + 1
l = [0] + [1] * (n - 1)
c = 2
while c < mx:
for k in range(2, floor(n/c) + 1):
l[c * k -1] = 0
c = l[:c].index(1) + c
return sum(l)
for n in stdin:
n = int(n)
print(cntPrime(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>
|
s601918800 | p00009 | Time Limit Exceeded | from math import sqrt,floor
from sys import stdin
def cntPrime(n):
mx = sqrt(n) + 1
if n % 2 == 0:
l = [0, 1] + [1, 0] * (int(n/2) - 1)
else:
l = [0, 1] + [1, 0] * (int(n/2) - 1) + [1]
c = 3
while c < mx:
for k in range(3, floor(n/c) + 1):
l[c * k -1] = 0
c = l[:c].index(1) + c
return sum(l)
for n in stdin:
n = int(n)
print(cntPrime(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>
|
s574788775 | p00009 | Time Limit Exceeded | from math import sqrt,floor
from sys import stdin
def cntPrime(n):
mx = sqrt(n) + 1
if n % 2 == 0:
l = [0, 1] + [1, 0] * (int(n/2) - 1)
else:
l = [0, 1] + [1, 0] * (int(n/2) - 1) + [1]
c = 3
while c < mx:
for k in range(c, floor(n/c) + 1, 1):
l[c * k -1] = 0
c = l[:c].index(1) + c
return sum(l)
for n in stdin:
n = int(n)
print(cntPrime(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>
|
s405190923 | p00009 | Time Limit Exceeded | from math import sqrt,floor
from sys import stdin
def cntPrime(n):
mx = sqrt(n) + 1
if n % 2 == 0:
l = [0, 1] + [1, 0] * (int(n/2) - 1)
else:
l = [0, 1] + [1, 0] * (int(n/2) - 1) + [1]
c = 3
while c < mx:
for k in range(c, floor(n/c) + 1, 1):
l[c * k -1] = 0
c = l[:c].index(1) + c
while c % 2 == 0:
c = l[:c].index(1) + c
return sum(l)
for n in stdin:
n = int(n)
print(cntPrime(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>
|
s334412597 | p00009 | Time Limit Exceeded | from math import sqrt,floor
from sys import stdin
def cntPrime(n):
mx = sqrt(n) + 1
if n % 2 == 0:
l = [0, 1] + [1, 0] * (int(n/2) - 1)
else:
l = [0, 1] + [1, 0] * (int(n/2) - 1) + [1]
c = 3
while c < mx:
for k in range(c*2, n+1, c):
l[k-1] = 0
c = l[:c].index(1) + c
return sum(l)
for n in stdin:
n = int(n)
print(cntPrime(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>
|
s514512803 | p00009 | Time Limit Exceeded | from math import sqrt,floor
from sys import stdin
def cntPrime(n):
mx = sqrt(n)
if n % 2 == 0:
l = [0, 1] + [1, 0] * (int(n/2) - 1)
else:
l = [0, 1] + [1, 0] * (int(n/2) - 1) + [1]
c = 3
while c < mx:
for k in range(c*2, n+1, c):
l[k-1] = 0
c = l[(c+1):].index(1) + c +2
while c % 2 == 0:
c = l[(c+1):].index(1) + c +2
return sum(l)
for n in stdin:
n = int(n)
print(cntPrime(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>
|
s946818754 | p00009 | Time Limit Exceeded | from math import sqrt
from sys import stdin
def isprime(x) :
if x == 2 : return x
elif (x < 2) or (x % 2 == 0) : return False
else :
i = 3
while i <= sqrt(x) :
if x % i == 0 : return False
i = i + 2
return x
for Input in stdin :
result = []
for make in range(2, int(Input) + 1) :
if isprime(make) != False : result.append(make)
print(len(result)) | 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>
|
s550584777 | p00009 | Time Limit Exceeded | from math import sqrt
from sys import stdin
def isprime(x) :
if x == 2 : return x
elif (x < 2) or (x % 2 == 0) : return False
else :
i = 3
while i <= sqrt(x) :
if x % i == 0 : return False
i = i + 2
return x
for Input in stdin :
result = 0
for make in range(2, int(Input) + 1) :
if isprime(make) != False : result += 1
print(result) | 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>
|
s951914801 | p00009 | Time Limit Exceeded | from math import sqrt
from sys import stdin
def isprime(x) :
i = 3
while i <= sqrt(x) :
if x % i == 0 : return False
i = i + 2
return x
for Input in stdin :
if int(Input) == 1 : print(0)
elif int(Input) == 2 : print(1)
else:
result = 1
for make in range(3, int(Input) + 1, 2) :
if isprime(make) != False : result += 1
print(result) | 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>
|
s202897314 | p00009 | Time Limit Exceeded | from math import sqrt
from sys import stdin
def isprime(x) :
i = 3
while i <= int(sqrt(x)) + 1 :
if x % i == 0 : return False
i = i + 2
return x
for Input in stdin :
if int(Input) == 1 : print(0)
elif int(Input) == 2 : print(1)
else:
result = 1
for make in range(3, int(Input) + 1, 2) :
if isprime(make) != False : result += 1
print(result) | 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>
|
s768876126 | p00009 | Time Limit Exceeded | import math
def main():
for _ in range(30):
number = int(input())
p = 0
for num in range(2, number+1):
a = int(math.sqrt(num))
c = 0
for k in range(2, a+1):
if num % k == 0:
c = 1
break
if c == 0:
p += 1
print(p)
return None
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>
|
s695284248 | p00009 | Time Limit Exceeded | import math
def main():
for _ in range(30):
try:
number = int(input())
except EOFError:
return None
p = 0
for num in range(2, number+1):
a = int(math.sqrt(num))
c = 0
for k in range(2, a+1):
if num % k == 0:
c = 1
break
if c == 0:
p += 1
print(p)
return None
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>
|
s425891628 | p00009 | Time Limit Exceeded | def main():
for _ in range(30):
try:
number = int(input())
except EOFError:
return None
p = 0
for num in range(2, number+1):
a = int(num**0.5)
bl = True
for k in range(2, a+1):
if num % k == 0:
bl = False
break
if bl:
p += 1
print(p)
return None
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>
|
s853414193 | p00009 | Time Limit Exceeded | import sys
def main():
for number in sys.stdin:
p = 0
number = int(number)
for num in range(2, number+1):
a = int(num**0.5)
bl = True
for k in range(2, a+1):
if num % k == 0:
bl = False
break
if bl:
p += 1
print(p)
return None
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>
|
s445342862 | p00009 | Time Limit Exceeded | import sys
def main():
for number in sys.stdin:
p = 0
number = int(number)
for num in range(1, number+1,2):
a = int(num**0.5)
bl = True
for k in range(2, a+1):
if num % k == 0:
bl = False
break
if bl:
p += 1
print(p)
return None
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>
|
s816081170 | p00009 | Time Limit Exceeded | import math
def lenPrimeNumber(num):
if num == 1:
return 1
else:
sList = list(range(2, num + 1))
pList = []
while sList[0] < math.sqrt(num):
pList.append(sList.pop(0))
sList = list(filter(lambda x: x % pList[-1] != 0, sList))
pList.extend(sList)
return len(list(map(lambda x: num % x == 0, pList)))
def inputGenerator():
while True:
try:
yield input()
except EOFError:
break
if __name__ == "__main__":
for x in list(inputGenerator()):
print(lenPrimeNumber(int(x))) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s633059010 | p00009 | Time Limit Exceeded | import itertools, functools, math, sys
def prime_stream():
stream = itertools.count(2)
sieve = lambda x, y: x % y != 0
while True:
prime = next(stream)
stream = filter(functools.partial(sieve, y=prime), stream)
yield prime
for line in sys.stdin:
primes = prime_stream()
num = int(line)
count = 0
for i in range(num):
if next(primes) > num:
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>
|
s425734345 | p00009 | Time Limit Exceeded | import sys
primes = [2, 3]
for n in range(5, 999999, 2):
isprime = True
for i in range(len(primes)):
if primes[i]**2 > n:
break
if n%primes[i] == 0:
isprime = False
break
if isprime:
primes.append(n)
numbers = []
count = 0
for line in sys.stdin:
numbers.append(int(line))
count += 1
counts = []
for i in range(count):
counts.append(0)
for prime in primes:
if prime > 999999:
break
for i in range(count):
if prime <= numbers[i]:
counts[i] += 1
for count in counts:
print(count) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s304380329 | p00009 | Time Limit Exceeded | import math, sys
def erastos(n):
n += 1
try:
v = [0 if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else 1 for i in range(n)]
v[0] = v[1] = 0
v[2] = v[3] = v[5] = 1
except IndexError:
return [0, 0, 1, 1, 0, 1][:n]
sqrt = math.sqrt(n)
for serial in range(3, n, 2):
if serial > sqrt:
return v
for s in range(serial ** 2, n, serial):
v[s] = 0
if __name__ == '__main__':
while True:
try:
n = int(input())
except:
break
v = erastos(n)
primes = [i for i, b in enumerate(v) if b == True]
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>
|
s888531488 | p00009 | Time Limit Exceeded | import math, sys
def erastos(n):
n += 1
try:
v = [0 if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else 1 for i in range(n)]
v[0] = v[1] = 0
v[2] = v[3] = v[5] = 1
except IndexError:
return [0, 0, 1, 1, 0, 1][:n]
sqrt = math.sqrt(n)
for serial in range(3, n, 2):
if serial > sqrt:
return v
for s in range(serial ** 2, n, serial):
v[s] = 0
if __name__ == '__main__':
while True:
try:
n = int(input())
v = erastos(n)
primes = [i for i, b in enumerate(v) if b == True]
print(len(primes))
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>
|
s424389362 | p00009 | Time Limit Exceeded | import math
def isPrime(n):
if n==1: return False
if n==2: return True
for i in range(2,int(math.sqrt(n))+2):
if n%i==0: return False
return True
while True:
a = input()
if a=='NULL': break
sum = 0
for i in range(1,a+1):
if isPrime(i)==True:
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>
|
s447603271 | p00009 | Time Limit Exceeded | import math
def isPrime(n):
if n==1: return False
if n==2: return True
for i in range(2,int(math.sqrt(n))+2):
if n%i==0: return False
return True
while True:
a = input()
if a=='EOF': break
sum = 0
for i in range(1,a+1):
if isPrime(i)==True:
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>
|
s919627744 | p00009 | Time Limit Exceeded | import math
def isPrime(n):
if n==1: return False
if n==2: return True
for i in range(2,int(math.sqrt(n))+2):
if n%i==0: return False
return True
while True:
try:
a = input()
if a=='EOF': break
sum = 0
for i in range(1,a+1):
if isPrime(i)==True:
sum+=1
print sum
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>
|
s444738773 | p00009 | Time Limit Exceeded | # coding: utf-8
# Here your code !
#coding:utf-8
import math
import sys
def flatten(L):
if isinstance(L, list):
if L == []:
return []
else:
return flatten(L[0]) + flatten(L[1:])
else:
return [L]
def Eratos(data):
p_list = [] # ????????????
tmp = []
num = int(math.sqrt(len(data)))+1
for i in data:
i=data[0]
if i>num:
break
else:
p_list.append(i)
for j in data:
if j%i == 0:
data.remove(j)
p_list.append(data)
return p_list
N = input()
a = []
lists = []
for line in sys.stdin:
# a.append(input())
# print(line)
x= list(range(2,(int(line)+1)))
print(len(flatten(Eratos(x))))
# r_list = list(range(2,(x+1)))
# ans = []
# ans = Eratos(r_list)
# print(len(flatten(ans))) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s129357698 | p00009 | Time Limit Exceeded | import math
import sys
def f(L):
if isinstance(L, list):
if L == []:
return []
else:
return f(L[0]) + f(L[1:])
else:
return [L]
def E(d):
p_list = []
tmp = []
num = int(math.sqrt(len(d)))+1
for i in d:
i=d[0]
if i>num:
break
else:
p_list.append(i)
for j in d:
if j%i == 0:
d.remove(j)
p_list.append(d)
return p_list
lists = []
for line in sys.stdin:
x= list(range(2,(int(line)+1)))
print(len(f(E(x)))) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s283413347 | p00009 | Time Limit Exceeded | import math
import sys
def E(d):
p_list = []
tmp = []
num = int(math.sqrt(len(d)))+1
for i in d:
i=d[0]
if i>num:
break
else:
p_list.append(i)
for j in d:
if j%i == 0:
d.remove(j)
print(len(p_list)+len(d))
# p_list.append(d)
# return p_list
lists = []
for line in sys.stdin:
x= list(range(2,(int(line)+1)))
E(x) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s603878634 | p00009 | Time Limit Exceeded | import math
import sys
def E(d):
p_list = []
tmp = []
num = int(math.sqrt(len(d)))+1
for i in d:
i=d[0]
if i>num:
break
else:
p_list.append(i)
for j in d:
if j%i == 0:
d.remove(j)
print(len(p_list)+len(d))
lists = []
for line in sys.stdin:
x= [i for i in range(2,(int(line)+1))]
E(x) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s300024556 | p00009 | Time Limit Exceeded | import math
import sys
def E(d):
p_list = []
p=0
tmp = []
l = len(d)
num = int(math.sqrt(len(d)))+1
for i in d:
i=d[0]
if i>num:
break
else:
# p_list.append(i)
p=p+1
for j in d:
if j%i == 0:
d.remove(j)
l = l-1
# print(len(p_list)+len(d))
print(p+l)
for line in sys.stdin:
x= [i for i in range(2,(int(line)+1))]
E(x) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s205251747 | p00009 | Time Limit Exceeded | import sys
def is_prime(x):
if(x <= 1):
return 0
i = 2
while(i <= x-1):
if(x % i == 0):
return 0
i += 1
return 1
a = []
i = 0
cnt = 0
for line in sys.stdin:
a.append(int(line))
cnt = 0
j = 1
while(j <= a[i]):
if(is_prime(j) == 1):
cnt += 1
j += 1
i += 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>
|
s883191784 | p00009 | Time Limit Exceeded | def main():
import sys
MAX = 1000000
table = [True]*1000000
table[0] = table[1] = False
primes = []
counted = 0
for line in sys.stdin:
n = int(line)
if n > counted:
for i in range(int(n+1)):
if table[i] and not i in primes:
primes.append(i)
for j in range(2*i, MAX, i):
table[j] = False
counted = n
cnt = 0
for prime in primes:
if prime > n:
break
else:
cnt += 1
print(primes)
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>
|
s288339539 | p00009 | Time Limit Exceeded | import sys
s=[2]
for i in range(3,999999):
for j in range(2,i-1):
if not i%j:break
else:
s.append(i)
# print(i)
for n in sys.stdin:
n=int(n)
cnt=0
for i,iv in enumerate(s):
if iv>n:
print(i)
break
else:
print(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>
|
s646157301 | p00009 | Time Limit Exceeded | import sys
max_v = max(int(string) for string in sys.stdin)
prime_list = [2]
for i in range(2, max_v + 1):
for prime in prime_list:
if i % prime == 0: break
else:
prime_list.append(i)
cnt = 0
for string in sys.stdin:
for i in range(int(string) + 1):
cnt += 1 if i in prime_list else 0
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>
|
s238461375 | p00009 | Time Limit Exceeded | import sys
def prime(n):
N = n + 1
ints = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(N)]
try:
ints[0] = ints[1] = False
ints[2] = ints[3] = ints[5] = True
except IndexError:
pass
sqrt = N ** 0.5
for i in range(3, N, 2):
if i >= sqrt:
break
for m in range(i ** 2, N, i):
ints[m] = False
return ints.count(True)
for line in sys.stdin:
print(prime(int(line))) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s310551641 | p00009 | Time Limit Exceeded | import sys
for user in sys.stdin:
n = int(user)
num = 1
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) | 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>
|
s992204591 | p00009 | Time Limit Exceeded | def isprime(x):
if x == 2:
return True
elif x < 2 or x%2 == 0:
return False
i = 3
while i <= pow(x,1/2):
if x%i == 0:
return False
i = i + 2
return True
import sys
import itertools as it
line = sys.stdin.readlines()
for n in line:
n = int(n)
count = 0
for s in range(2,n+1):
if isprime(s):
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>
|
s489439786 | p00009 | Time Limit Exceeded | def isprime(x):
if x == 2:
return True
elif x < 2 or x%2 == 0:
return False
i = 3
while i <= pow(x,1/2):
if x%i == 0:
return False
i = i + 2
return True
import sys
import itertools as it
line = sys.stdin.readlines()
for n in line:
n = int(n)
if n == 2:
print(1)
else:
count = 1
for s in range(3,n+1,2):
if isprime(s):
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>
|
s685665611 | p00009 | Time Limit Exceeded | import sys
def main():
for line in sys.stdin:
n = int(line)
hoge = [i for i in range(2, n + 1) if i % 2 != 0 or i == 2]
fuga = [2]
for i in range(1, len(hoge)):
cnt = 0
for j in range(i):
if hoge[i] % hoge[j] != 0:
cnt += 1
if cnt == i:
fuga.append(hoge[i])
print(len(fuga))
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>
|
s135319614 | p00009 | Time Limit Exceeded | while 1:
try:
count=0;
x=int(input())
if x==1:
print(0)
elif x==2:
print(1)
else:
a=[int(i) for i in range(2,x+1)]
for i in range(len(a)):
count1=0
for j in range(2,a[i]):
if a[i]%j==0:
count1+=1
if count1==0:
count+=1
print(count)
except EOFError:
break | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s916035384 | p00009 | Time Limit Exceeded | while 1:
try:
b=[]
count=1
x=int(input())
if x==1:
print(0)
elif x==2:
print(1)
else:
for i in range(3,x+1):
count1=0
for j in range(2,i):
if i%j==0:
count1=1
break
if count1==0:
count+=1
print(count)
except EOFError:
break | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s033531368 | p00009 | Time Limit Exceeded | b=[]
b.append(1)
b.append(2)
count=1
while 1:
try:
x=int(input())
if x>b[count]:
for i in range(b[count]+1,x+1):
count1=0
for j in range(2,i):
if i%j==0:
count1=1
break
if count1==0:
count+=1
b.append(i)
print(count)
else:
for i in range(count+1):
if b[i]>x:
print(i-1)
break
elif b[i]==x:
print(i)
break
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>
|
s083913132 | p00009 | Time Limit Exceeded | b=[]
b.append(1)
b.append(2)
count=1
s=0
while s<30:
try:
x=int(input())
if x>b[count]:
for i in range(b[count]+1,x+1):
count1=0
for j in range(2,i):
if i%j==0:
count1=1
break
if count1==0:
count+=1
b.append(i)
print(count)
else:
for i in range(count+1):
if b[i]>x:
print(i-1)
break
elif b[i]==x:
print(i)
break
s+=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>
|
s209117635 | p00009 | Time Limit Exceeded | import math
b=[]
b.append(1)
b.append(2)
count=1
s=0
while s<30:
try:
x=int(input())
if x>b[count]:
for i in range(b[count]+1,x+1):
count1=0
for j in range(2,int(math.sqrt(i))+1):
if i%j==0:
count1=1
break
if count1==0:
count+=1
b.append(i)
print(count)
else:
for i in range(count+1):
if b[i]>x:
print(i-1)
break
elif b[i]==x:
print(i)
break
s+=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>
|
s463859820 | p00009 | Time Limit Exceeded | import math
b=[]
b.append(1)
b.append(2)
count=1
s=0
while s<30:
try:
x=int(input())
if x>b[count]:
for i in range(b[count]+1,x+1):
count1=0
for j in range(2,int(math.sqrt(i))+1):
if i%j==0:
count1=1
break
if count1==0:
count+=1
b.append(i)
print(count)
print(b)
else:
for i in range(count+1):
if b[i]>x:
print(i-1)
break
elif b[i]==x:
print(i)
break
s+=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>
|
s388625909 | p00009 | Time Limit Exceeded | from collections import deque
import bisect
from math import sqrt
import sys
primes = deque([2, 3, 5, 7, 11, 13, 17, 19])
append = primes.append
for i in range(21, 1000000, 2):
for j in range(3, int(sqrt(i))+1, 2):
if i%j == 0:
break
else:
append(i)
for l in sys.stdin:
print(bisect.bisect(primes, int(l))) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s324099352 | p00009 | Time Limit Exceeded | def check_prime(goal):
true_or_false=False
for i in range(2,goal):
if goal%i==0:
true_or_false=True
if true_or_false==False:
return True
else:
return False
anss=[]
while True:
try:
num=int(input())
num_of_prime=0
for i in range(2,num+1):
if check_prime(i):
num_of_prime+=1
anss.append(num_of_prime)
except:
break
for ans in anss:
print(ans) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s708254408 | p00009 | Time Limit Exceeded | def check_prime(goal):
true_or_false=False
for i in range(2,goal):
if goal%i==0:
true_or_false=True
break
if true_or_false==False:
return True
else:
return False
anss=[]
while True:
try:
num=int(input())
num_of_prime=0
for i in range(2,num+1):
if check_prime(i):
num_of_prime+=1
anss.append(num_of_prime)
except:
break
for ans in anss:
print(ans) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s310129059 | p00009 | Time Limit Exceeded | def check_prime(goal):
true_or_false=False
for i in range(2,goal):
if goal%i==0:
true_or_false=True
break
if true_or_false==False:
return True
else:
return False
anss=[]
while True:
try:
num=int(input())
num_of_prime=0
for i in range(2,num+1):
if check_prime(i):
num_of_prime+=1
anss.append(num_of_prime)
except:
break
for ans in anss:
print(ans) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s969576096 | p00009 | Time Limit Exceeded | import math
def check_prime(goal):
true_or_false=False
for i in range(2,goal):
if goal%i==0:
true_or_false=True
if true_or_false==False:
return True
else:
return False
anss=[]
while True:
try:
num=int(input())
num_of_prime=0
for i in range(2,num+1):
if check_prime(i):
num_of_prime+=1
anss.append(num_of_prime)
except:
break
for ans in anss:
print(ans) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s879319631 | p00009 | Time Limit Exceeded | import math
def check_prime(goal):
true_or_false=False
for i in range(2,int(math.sqrt(goal))+1):
if goal%i==0:
true_or_false=True
if true_or_false==False:
return True
else:
return False
anss=[]
while True:
try:
num=int(input())
num_of_prime=0
for i in range(2,num+1):
if check_prime(i):
num_of_prime+=1
anss.append(num_of_prime)
except:
break
for ans in anss:
print(ans) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s952897627 | p00009 | Time Limit Exceeded | def e(n):
array = [1]*(n+1)
k = 2
while k*k <= n:
if array[k] == 1:
i = k
while (i <= n/k):
array[k*i] = 0
i += 1
k += 1
# ?´???°(array[i]==1)?????????
prime = []
i = 2
while i <= n:
if array[i] == 1:
prime.append(i)
i += 1
return len(prime)
while True:
try:
n = int(input())
print(e(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>
|
s531008097 | p00009 | Time Limit Exceeded | t = 0
while t == 0:
prime = [2]
try:
n = int(input())
except:
break
#?¨??????\???????????????????¨????
else:
if n == 1:
#1?????????
print(0)
else:
for a in range(2,n + 1):
#2??\????????????
total = len(prime)
#?´???°?????°?????????
for b in prime:
if a % b == 0:
break
#?´???°??????????????´????????????
else:
if total == 0:
#?´???°?¢?????????????
prime.append(a)
else:
#?´???°??¢?´¢??°??????
total -= 1
print(len(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>
|
s341964758 | p00009 | Time Limit Exceeded | def e(n):
array = [1]*(n+1)
k = 2
while k*k <= n:
if array[k] == 1:
i = k
while (i <= n/k):
array[k*i] = 0
i += 1
k += 1
prime = []
i = 2
while i <= n:
if array[i] == 1:
prime.append(i)
i += 1
return len(prime)
while True:
try:
n = int(input())
print(e(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>
|
s531027774 | p00009 | Time Limit Exceeded | t = 0
while t == 0:
prime = [2,3]
try:
n = int(input())
except:
break
#?¨??????\???????????????????¨????
else:
if n == 1:
#1?????????
print(0)
elif n == 2:
print(1)
else:
a = 5
while a > n:
#5??\????????????
total = len(prime)
#?´???°?????°?????????
for b in prime:
if a % b == 0:
break
#?´???°??????????????´????????????
else:
if total == 0:
#?´???°?¢?????????????
prime.append(a)
else:
#?´???°??¢?´¢??°??????
total -= 1
if (a + 1) % 6 == 0:
a += 2
else:
a += 5
print(len(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>
|
s146642928 | p00009 | Time Limit Exceeded | num = []
while True:
try:
num.append(int(input()))
except EOFError:
break
lst = [i for i in range(2, max(num)+1)]
for i in lst[::-1]:
for j in range(2, i):
if i % j == 0:
lst.pop(lst.index(i))
break
lst.append(lst[-1]+1)
for i in num:
for j in lst:
if i < j:
print(lst.index(j))
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>
|
s921538702 | p00009 | Time Limit Exceeded | num = []
while True:
try:
num.append(int(input()))
except EOFError:
break
lst = [i for i in range(2, max(num)+1)]
for i in lst[::-1]:
for j in range(2, i):
if i % j == 0:
lst.pop(lst.index(i))
break
for i in num:
for j in lst:
if i < j:
print(lst.index(j))
break
elif i == j:
print(lst.index(j)+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>
|
s205865722 | p00009 | Time Limit Exceeded | import sys
num = []
for i in sys.stdin:
num.append(int(i))
lst = [i for i in range(2, max(num)+1)]
for i in lst[::-1]:
for j in range(2, i):
if i % j == 0:
lst.pop(lst.index(i))
break
for i in num:
for j in lst:
if i < j:
print(lst.index(j))
break
elif i == j:
print(lst.index(j)+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>
|
s556305327 | p00009 | Time Limit Exceeded | import sys
for line in sys.stdin:
lis = []
i = 2
while i <= int(line):
j = 1
while j <= i-2:
if i % (j+1) == 0:
break
j += 1
else:
lis.append(i)
i += 1
print len(lis) | 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>
|
s197754724 | p00009 | Time Limit Exceeded | import sys
for line in sys.stdin:
i = 5
lis = [2,3]
while i <= int(line):
if i % 3 != 0:
j = 5
while j <= int(i**0.5):
if j % 3 != 0:
if i % j == 0:
break
j += 2
else:
lis.append(i)
i += 2
print len(lis) | 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>
|
s143125853 | p00009 | Time Limit Exceeded | def is_prime(q):
q = abs(q)
if q == 2: return True
if q < 2 or q&1 == 0: return False
return pow(2, q-1, q) == 1
t = 0
while t == 0:
try:
x = 5
except:
break
else:
n = 1
if x == 0 or x == 1:
print(0)
elif x == 2:
print(1)
else:
for i in range(0,x + 1,2):
if is_prime(i):
n += 1
print(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>
|
s207181181 | p00009 | Time Limit Exceeded | # -*-coding:utf-8
#n??\???????´???°?????°
import fileinput
import math
def main():
for line in fileinput.input():
tokens = list(map(int, line.strip().split()))
primeNumber = tokens[0]
ans = 1
for i in range(3, primeNumber+1, 2):
flag = 0
for j in range(3, int(math.sqrt(i))+1, 2):
if(i%j == 0):
flag = 1
break
if(flag == 0):
ans += 1
print(ans)
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>
|
s518396162 | p00009 | Time Limit Exceeded | import sys
import math
#from me.io import dup_file_stdin
primes = [2,3,5,7]
def isPrime(x):
if x<=primes[-1]:
return x in primes
else:
for prime in primes:
if x%prime==0:
return False
else:
current=primes[-1]
dst=math.sqrt(x)
while current<dst:
if(x%current==0):
return False
else:
return True
#@dup_file_stdin
def solve():
for query in map(int,sys.stdin):
if(query>primes[-1]):
for i in range(primes[-1]+1,query+1):
if isPrime(i):
primes.append(i);
print(len([x for x in primes if x<=query]))
solve() | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s021716544 | p00009 | Time Limit Exceeded | MAX = 999999
def is_prime(n):
if n == 2:return True
if n % 2 == 0:return False
for i in range(3,int(n**0.5)+1,2):
if n % i == 0:return False
return True
def prime_list(n):
result = 0
if n >= 2:result+=1
for i in range(3,n+1,2):
if is_prime(i):result+=1
return result
while 1:
print(prime_list(int(input()))) | 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>
|
s642633589 | p00009 | Time Limit Exceeded | import sys
L = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]
def is_prime_2(n):
a = int(n ** 0.5)
for i in L:
if i > a:return True
if n % i == 0:return False
return True
def prime_count(n):
result = 0
if n >= 2:result+=1
for i in range(3,n+1,2):
if is_prime_2(i):result+=1
return result
for n in sys.stdin:
print(prime_count(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>
|
s220621275 | p00009 | Time Limit Exceeded | import sys
MAX = 999999
L = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]
def is_prime(n):
if n == 2:return True
if n % 2 == 0:return False
for i in range(3,int(n**0.5)+1,2):
if n % i == 0:return False
return True
def is_prime_2(n):
a = int(n ** 0.5)
for i in L:
if i > a:return True
if n % i == 0:return False
return True
def prime_count(n):
result = 0
if n >= 2:result+=1
for i in range(3,n+1,2):
if is_prime_2(i):result+=1
return result
def prime_list(n):
result = []
if n >= 2:result.append(2)
for i in range(3,n+1,2):
if is_prime(i):result.append(i)
return result
L2 = prime_list(MAX)
def prime_count_2(n):
for i,v in enumerate(n):
if n > v:return i
return len(L2)
for n in sys.stdin:
print(prime_count(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>
|
s832759386 | p00009 | Time Limit Exceeded | import sys
num = []
for i in sys.stdin:
num.append(int(i))
lst = [i for i in range(2, max(num))]
for i in lst[::-1]:
for j in range(2, i):
if i % j == 0:
lst.pop(lst.index(i))
break
for i in num:
for j in lst:
if i < j:
print(lst.index(j))
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>
|
s177773656 | p00009 | Time Limit Exceeded | import sys
N = 1000000
lst = []
for i in range(2, N):
lst.append(i)
for j in range(2, i):
if i % j == 0:
lst.pop(lst.index(i))
break
for i in sys.stdin:
for j in range(len(lst)):
if lst[j] <= int(i):
print(j+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>
|
s446643307 | p00009 | Time Limit Exceeded | import sys
for line in sys.stdin:
lis = []
num = int(line)
if num >= 2:
lis.append(2)
if num >= 3:
lis.append(3)
if num >= 5:
for i in xrange(5,num+1,2):
for item in lis:
if item > (i**0.5):
lis.append(i)
break
if i % item == 0:
break
else:
lis.append(i)
print len(lis) | 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>
|
s826794818 | p00009 | Time Limit Exceeded | import math
while True:
try:
c = 0
n = int(input())
for i in range(n,1,-1):
if i == 2:
c += 1
break
elif i%2 == 0:
continue
else:
j = 3
while j <= math.sqrt(i):
if i%j == 0:
break
j += 2
else:
c += 1
print(c)
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>
|
s807957153 | p00009 | Time Limit Exceeded | import math
while True:
try:
n = int(input())
c = [1 for i in range(n)]
c[0] = 0
i = 2
while i**2 <= n:
j = i*2
while j <= n:
c[j - 1] = 0
j += i
i += 1
print(sum(c))
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>
|
s193893253 | p00009 | Time Limit Exceeded | from sys import stdin
def prime(n: int) -> int:
Prime = [i for i in range(n+1)]
for i in range(2,n+1):
for j in range(2,int(n/i)+1):
Prime[i*j] = 0
Prime[0],Prime[1] = 0,0
print(Prime)
ans = [i for i in Prime if not(i == 0)]
return len(ans)
for line in stdin:
n = int(line)
print(prime(n)) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s148478023 | p00009 | Time Limit Exceeded | from sys import stdin
def prime(n):
Prime = [i for i in range(n + 1)]
for i in range(2, n + 1):
for j in range(2, int(n / i) + 1):
Prime[i * j] = 0
Prime[0], Prime[1] = 0, 0
ans = [i for i in Prime if not (i == 0)]
return len(ans)
for line in stdin:
n = int(line)
print(prime(n)) | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s281364525 | p00009 | Time Limit Exceeded | from sys import stdin
def prime(n):
Prime = [i for i in range(n + 1)]
for i in range(2, n + 1):
for j in range(2, int(n / i) + 1):
Prime[i * j] = 0
Prime[0], Prime[1] = 0, 0
ans = [i for i in Prime if not (i == 0)]
return len(ans)
Ans = []
for line in stdin:
n = int(line)
Ans.append(prime(n))
for po in Ans:
print(po) | 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>
|
s691208075 | p00009 | Time Limit Exceeded | import math
def main():
while True:
try:
n = int(input())
count = 0
for x in range(2,n+1):
flag = 0
for i in range(2,x):
if x%i == 0:
flag = 1
break
if flag == 0:
count += 1
print(count)
except EOFError:
exit()
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>
|
s030575236 | p00009 | Time Limit Exceeded | import math
def main():
while True:
try:
n = int(input())
count = 0
for x in range(2,n+1):
flag = 0
for i in range(2,int(n**0.5)):
if x%i == 0:
flag = 1
break
if flag == 0:
count += 1
print(count)
except EOFError:
exit()
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>
|
s145156560 | p00009 | Time Limit Exceeded | import math
def main():
while True:
try:
n = int(input())
count = 0
for x in range(2,n+1):
flag = 0
for i in range(2,int(n**0.5)):
if x%i == 0:
flag = 1
break
if flag == 0:
count += 1
if n == 2:
n += 1
print(count)
except EOFError:
exit()
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>
|
s491279243 | p00009 | Time Limit Exceeded | count = 1
while True:
try:
n = int(raw_input())
for i in range(3, n+1):
#print i
for j in range(2, i):
if i == j+1:
count += 1
#print i
#print 111
break
elif i % j ==0:
#print 222
break
else:
#print 333
continue
#count += 1
#print 99999999
except:
break
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>
|
s908496555 | p00009 | Time Limit Exceeded | while True:
try:
n = int(raw_input())
count = 1
for i in range(3, n+1):
#print i
for j in range(2, i):
if i == j+1:
count += 1
#print i
#print 111
break
elif i % j ==0:
#print 222
break
else:
#print 333
continue
#count += 1
#print 99999999
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>
|
s259826889 | p00009 | Time Limit Exceeded | import sys
for line in sys.stdin:
try:
n = int(line)
primes = [2]
for i in range(3, n + 1):
primes.append(i)
for p in primes:
if i % p == 0 and i != p:
primes.pop()
break
ans = [i for i in primes if i <= n]
print(len(ans))
except:
break | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s512882142 | p00009 | Time Limit Exceeded | import sys
primes = [2]
for line in sys.stdin:
try:
n = int(line)
for i in range(max(primes) + 1, n + 1):
primes.append(i)
for p in primes:
if i % p == 0 and i != p:
primes.pop()
break
ans = [i for i in primes if i <= n]
print(len(ans))
except:
break | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s047385554 | p00009 | Time Limit Exceeded | import sys
primes = [2]
for line in sys.stdin:
try:
n = int(line)
if n > max(primes):
for i in range(max(primes) + 1, n + 1):
primes.append(i)
for p in primes:
if i % p == 0 and i != p:
primes.pop()
break
ans = [i for i in primes if i <= n]
print(len(ans))
except:
break | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s489762502 | p00009 | Time Limit Exceeded | import sys
primes = [2]
for line in sys.stdin:
try:
n = int(line)
if n > max(primes):
for i in range(max(primes) + 1, n + 1):
if i % 2 == 0:
continue
primes.append(i)
for p in primes:
if i % p == 0 and i != p:
primes.pop()
break
ans = [i for i in primes if i <= n]
print(len(ans))
except:
break | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s665785185 | p00009 | Time Limit Exceeded | import sys
primes = [2]
for line in sys.stdin:
try:
n = int(line)
if n > max(primes):
for i in range(max(primes) + 1, n + 1):
if i % 2 == 0 or i % 3 == 0:
continue
primes.append(i)
for p in primes:
if i % p == 0 and i != p:
primes.pop()
break
ans = [i for i in primes if i <= n]
print(len(ans))
except:
break | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s091522568 | p00009 | Time Limit Exceeded | import sys
primes = [2]
for line in sys.stdin:
try:
n = int(line)
if n > max(primes):
for i in range(max(primes) + 1, n + 1):
if i % 2 == 0 or len([j for j in primes if i % j == 0]) > 0:
continue
primes.append(i)
ans = [i for i in primes if i <= n]
print(len(ans))
except:
break | 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s008929536 | p00009 | Time Limit Exceeded | import sys
def count_prime(x):
temp = 0
for i in range(2,x+1):
for j in range(2,i+1):
if(j == i):
temp += 1
elif(i % j == 0):
break
return temp
l = []
for input in sys.stdin:
l.append(input)
print l
for input in l:
print count_prime(int(input))
| 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>
|
s492335159 | p00009 | Time Limit Exceeded | import sys
def count_prime(x):
temp = 0
if(x > 2):
temp += 1
for i in range(3,x+1,2):
if(i % 2 == 0):
continue
for j in range(3,i+1,2):
if(j == i):
temp += 1
elif(i % j == 0):
break
return temp
l = []
for input in sys.stdin:
l.append(input)
print l
for input in l:
print count_prime(int(input))
| 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>
|
s591432073 | p00009 | Time Limit Exceeded | import sys
def is_prime(n):
if n <= 1:
return 0
elif n <= 3:
return 1
elif (n % 2 == 0 or n % 3 == 0):
return 0
i = 5
while ((i * i) <= n):
if (n % i == 0 or n % (i + 2) == 0):
return 0
i += 6
return 1
def count_prime(x):
temp = 0
if(x > 2):
temp += 1
for i in range(3,x+1,2):
if(is_prime(i) == 1):
temp += 1
return temp
l = []
for input in sys.stdin:
l.append(input)
print l
for input in l:
print count_prime(int(input))
| 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>
|
s186303064 | p00009 | Time Limit Exceeded | while True:
try:
n = int(input())
except:
break
p_table = list(range(2,n+1))
p = 2
i = 0
while i < len(p_table):
p = p_table[i]
j = p + p
while j <= n:
if j in p_table:
p_table.remove(j)
j += p
i += 1
print(len(p_table))
| 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>
|
s374006987 | p00009 | Time Limit Exceeded | import sys
num_of_data = 0
while True:
if num_of_data >= 30:
break
try:
n = int(input())
if n >= 1 and n <= 999999:
cnt = 0
for i in range(1, n+1):
flag = 0
for j in range(1, i+1):
if i%j == 0:
flag += 1
if flag == 2:
cnt += 1
print(cnt)
num_of_data += 1
except EOFError:
sys.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>
|
s506013783 | p00009 | Time Limit Exceeded | import sys
import math
def isPrime(n):
if n < 2:
return 0
elif n == 2:
return 1
elif n%2 == 0:
return 0
num = int(math.sqrt(n))
for i in range(3, num+1, 2):
if n%i == 0:
return 0
return 1;
while True:
try:
n = int(input())
cnt = 0
for i in range(2, n+1):
cnt += isPrime(i)
print(cnt)
except EOFError:
sys.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>
|
s821962404 | p00009 | Time Limit Exceeded | import sys
import math
def isPrime(n):
if n < 2:
return 0
elif n == 2:
return 1
elif n%2 == 0:
return 0
num = int(math.sqrt(n))
for i in range(3, num+1, 2):
if n%i == 0:
return 0
return 1;
while True:
try:
n = input()
if n == '':
break
n = int(n)
cnt = 0
for i in range(2, n+1):
cnt += isPrime(i)
print(cnt)
except EOFError:
sys.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>
|
s298903090 | p00009 | Time Limit Exceeded | def prime_count(N):
primes = [2, 3]
count = 1
for n in range(5, N+1, 2):
isprime = True
for i in range(1, len(primes)):
if primes[i] ** 2 > n:
break
if n % primes[i] == 0:
isprime = False
break
if isprime:
count += 1
return count
while True:
try:
print(prime_count(int(input())))
except:
break
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s180797939 | p00009 | Time Limit Exceeded | import sys
lines = sys.stdin.readlines()
for line in lines:
a = int(line)
b = [False, False]
for i in range(a-1):
b.append(True)
for i in range(a):
if(b[i]):
k = i
while(k <= a-i):
k += i
b[k] = False
cnt = 0
for i in b:
if(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>
|
s884079726 | p00009 | Time Limit Exceeded | import sys
lines = sys.stdin.readlines()
for line in lines:
a = int(line)
b = [False, False]
for i in range(a-1):
b.append(True)
for i in range(a):
if(b[i]):
k = i
while(k <= a-i):
k += i
b[k] = False
#print(b)
cnt = 0
for i in b:
if(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>
|
s475133148 | p00009 | Time Limit Exceeded | import math
def prime_judge(n):
if n==1:
return False
elif n==2:
return True
elif n%2==0:
return False
else:
sqrt_num=math.ceil(math.sqrt(n))+1
for i in range(3,sqrt_num, 2):
if n%i==0:
return False
return True
def prime_count(n):
count=0
for i in range(1,n+1):
if prime_judge(i):
count+=1
print(count)
while 1:
try:
prime_count(int(input()))
except EOFError:
break
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s566167493 | p00009 | Time Limit Exceeded | import math
def prime_judge(n):
if n==1:
return False
elif n==2:
return True
elif n%2==0:
return False
else:
sqrt_num=math.ceil(math.sqrt(n))+1
for i in range(3,sqrt_num, 2):
if n%i==0:
return False
return True
def prime_count(n):
count=0
for i in range(1,n+1):
if prime_judge(i):
count+=1
print(count)
while 1:
try:
prime_count(int(input()))
except:
break
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s007869563 | p00009 | Time Limit Exceeded | def prime(n):
seq = list(range(2, n+1))
while len(seq) > 0:
prime = seq.pop(0)
yield prime
seq = [i for i in seq if not i % prime == 0]
while True:
try:
n=input()
print len( list(prime(n)) )
except EOFError:
break
| 10
3
11
| 4
2
5
|
<H1>Prime Number</H1>
<p>
Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. Each dataset has an integer <var>n</var> (1 ≤ <var>n</var> ≤ 999,999) in a line.
</p>
<p>
The number of datasets is less than or equal to 30.
</p>
<H2>Output</H2>
<p>
For each dataset, prints the number of prime numbers.
</p>
<H2>Sample Input</H2>
<pre>
10
3
11
</pre>
<H2>Output for the Sample Input</H2>
<pre>
4
2
5
</pre>
|
s311812499 | p00009 | Time Limit Exceeded | import sys
for i in sys.stdin:
n = int(i)
if n <= 3:
print(max(0, n - 1))
continue
a = [2, 3]
for k in range(5, n + 1, 2):
for e in a:
if k % e == 0:
break
else:
a.append(k)
print(len(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>
|
s895881838 | p00009 | Time Limit Exceeded | def isPrime(num):
if num == 1:
return False
elif num == 2:
return True
elif num % 2 == 0:
return False
else:
for i in range(3, int(num ** 0.5) + 1, 2):
if num % i == 0:
return False
return True
while True:
try:
n = int(input())
except EOFError:
break
count = 0
for i in range(1, n + 1):
count += 1 if isPrime(i) else 0
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>
|
s725023433 | p00009 | Time Limit Exceeded | from sys import stdin
for limit in stdin:
limit = int(limit)
arr = [2,3,5,7]
def PrimeNumber(arr,number):
for i in arr:
if (number%i==0):
return False
return True
for i in range(2,limit+1):
if(PrimeNumber(arr,i)):
arr.append(i)
count = 0
for i in arr:
if (i>limit):
break
else:
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>
|
s950325825 | p00009 | Time Limit Exceeded | import sys
for limit in sys.stdin:
limit = int(limit)
arr = [2,3,5,7]
def PrimeNumber(arr,number):
for i in arr:
if (number%i==0):
return False
return True
for i in range(2,limit+1):
if(PrimeNumber(arr,i)):
arr.append(i)
count = 0
for i in arr:
if (i>limit):
break
else:
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>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.