submission_id
string
problem_id
string
status
string
code
string
input
string
output
string
problem_description
string
s969357122
p00009
Runtime Error
import sys ?? ary=[] for i in sys.stdin: ????????ary.append(int(i)) m = max(ary) prime=[1] * (m + 1) prime[0] = prime[1] = 0 for i in range(2, int(m ** 0.5) + 1): ????????if prime[i] == 1: ????????????????for j in range(i*2, m + 1, i): ????????????????????????prime[j] = 0 for i in range(len(ary)): ????????print(sum(prime[:ary[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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s851930830
p00009
Runtime Error
def isprime(num): if num==1:return False if num==2:return True for i in range(int(num/2)): if num%(i+2)==0: return False else:continue return True def ct(num): count=0 for i in range(num): if isprime(i+1):count+=1 return count def yak(num): if isprime(num):return [1,num] if num==1: return[1] for i in range(int(num/2)): if num%(i+2)==0: ret=yak(i+2)+yak(num/(i+2)) ret.remove(1) return sorted([int(i) for i in ret]) while True: try:raw=[float(i) for i in input().split(" ")] except:break a=raw[0] print(str(ct(a)))
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s053836402
p00009
Runtime Error
# -*- coding: utf-8 -*- import sys def prime(n): s = [i for i in range(2,n+1)] p = [] while s[0] < n**0.5: p.append(s[0]) for ss in s: if ss % p[-1] == 0: s.remove(ss) p.extend(s) return p def main(): inp = [int(n) for n in sys.stdin] for n in inp: n_pn = len(prime(n)) print(n_pn) 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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s532827913
p00009
Runtime Error
# -*- coding: utf-8 -*- import sys def prime(n): s = [i for i in range(2,n+1)] p = [] while s[0] < n**0.5: p.append(s[0]) for ss in s: if ss % p[-1] == 0: s.remove(ss) p.extend(s) return p def main(): inp = [int(n) for n in sys.stdin] for n in inp: n_pn = len(prime(n)) print n_pn 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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s983434059
p00009
Runtime Error
import numpy as np def PI(n): N_MAX = int(np.sqrt(n+1)) is_prime = np.ones((n+1,),dtype=bool) is_prime[:2] = 0 for i in range(2,N_MAX+1): is_prime[2*i::i] = 0 return sum(is_prime) def main(): print(PI(int(input()))) 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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s435700388
p00009
Runtime Error
import sys values = [] for line in sys.stdin: if 1000000 > int(line): values.append(line) for val in values: prime = 0 for i in range(2, val // 2): if val % i != 0: prime += 1 print(prime)
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s585935732
p00009
Runtime Error
while True: ss=input() if len(ss)==0: break s=int(ss)+1 if s<2: print(0) else: list=[True]*s list[0]=False list[1]=False i=2 while i**2<=s-1: j=i*2 while j<=s-1: list[j]=False j+=i i+=1 print(list.count(True))
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s355875939
p00009
Runtime Error
prime=[False]*1000000 np=[0]*1000000 for i in range(2,1000): if not prime[i] for j in range(i*2,1000000,i): prime[j]=True while True: try: n=int(input()) except: break print(sum(prime[2:n+1]))
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s246652104
p00009
Runtime Error
prime=[False]*1000000 np=[0]*1000000 for i in range(2,1000): if not prime[i] for j in range(i*2,1000000,i): prime[j]=True while True: try: n=int(input()) except: break print(sum(prime[2:n+1]))
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s738033026
p00009
Runtime Error
import sys from math import sqrt for line in sys.stdin: n = int(line.strip()) L, pn, tmp = int(sqrt(n)), [], [i for i in range(2, n+1)] while tmp[0] < L+1: v = tmp.pop(0) pn.append(v) tmp = list(filter(lambda x: x%v!=0, tmp)) for t in tmp: pn.append(t) print(len(pn))
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s502097216
p00009
Runtime Error
def isp(n): a = 1 for i in range(2, (n + 1) // 2 + 2): if not n % i: a = 0 break return a num = input() if num == 2: print(1) elif num == 3: print(2) else: s = 2 for x in range(2, num + 1): if isp(x): s += 1 print(s)
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s851257398
p00009
Runtime Error
def isp(n): a = 1 for i in range(2, (n + 1) // 2 + 2): if not n % i: a = 0 break return a num = input(int) if num == 2: print(1) elif num == 3: print(2) else: s = 2 for x in range(2, num + 1): if isp(x): s += 1 print(s)
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s520973407
p00009
Runtime Error
def isp(n): a = 1 for i in range(2, (n + 1) // 2 + 2): if not n % i: a = 0 break return a for i in sys.stdin: n = int(i) if num == 2: print(1) elif num == 3: print(2) else: s = 2 for x in range(2, num + 1): if isp(x): s += 1 print(s)
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s883815883
p00009
Runtime Error
import sys def primes(n): f = [] for i in range(n + 1): if i > 2 and i % 2 == 0: f.append(0) else: f.append(1) i = 3 while i * i <= n: if f[i] == 1: j = i * i while j <= n: f[j] = 0 j += i + i i += 2 return f[2:] if __name__ == "__main__": ps = primes(100) for i in sys.stdin: print(i,sum(ps[: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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s017889370
p00009
Runtime Error
import sys x = 500000 f = [0, 1] * xx i = 3 while i * i <= 2 * xx: if f[i] == 1: j = i * i while j <= 2 * xx: f[j] = 0 j += i + i i += 2 f.pop(0) f.pop(1) for n in sys.stdin: i = int(n) if i < 2: print(0) else: print(sum(f[:i - 1]))
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s592551884
p00009
Runtime Error
import sys x = 500000 f = [0, 1] * xx i = 3 while i * i <= 2 * xx: if f[i] == 1: j = i * i while j <= 2 * xx: f[j] = 0 j += i + i i += 2 f.pop(0) f.pop(1) for n in sys.stdin: i = int(n) if i < 2: print(0) else: print(sum(f[:i - 1]))
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s117291632
p00009
Runtime Error
import sys f = [0, 1] * 500000 i = 3 while i * i <= 2 * xx: if f[i] == 1: j = i * i while j <= 2 * xx: f[j] = 0 j += i + i i += 2 f.pop(0) f.pop(1) for n in sys.stdin: i = int(n) if i < 2: print(0) else: print(sum(f[:i - 1]))
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s390494308
p00009
Runtime Error
import sys lalala = 1000000 // 6 + 1 f = [1, 0, 0, 0, 1, 0] * lalala f = [0, 0, 1, 1] + f[3:-2] i = 5 while i < 1000: if f[i] == 1: j = i * i while j <= 1000000: f[j] = 0 j += i + i i += 2 for n in sys.stdin: i = int(n) print(sum(f[:i + 1]))
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s430488092
p00009
Runtime Error
def p(n): l = list(range(2,n+1)) p = 2 i = 0 p = l[i] while True: pl = len(l) l = list(filter(lambda n: n%p != 0 or n == p,l)) i += 1 p = l[i] if pl == len(l): break return len(l) from sys import stdin for i in stdin: print(p(int(i)))
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s416871680
p00009
Runtime Error
def p(n): l = list(range(2,n+1)) p = 2 i = 0 p = l[i] while True: pl = len(l) l = list(filter(lambda n: n%p != 0 or n == p,l)) i += 1 p = l[i] if pl == len(l): return pl from sys import stdin for i in stdin: print(p(int(i)))
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s051465539
p00009
Runtime Error
from math import sqrt def p(n): l = list(range(2,n+1)) p = 2 i = 0 p = l[i] while p < sqrt(n): pl = len(l) l = list(filter(lambda n: n%p != 0 or n == p,l)) i += 1 p = l[i] return len(l) from sys import stdin for i in stdin: print(p(int(i)))
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s327350232
p00009
Runtime Error
def pm(n): l = list(range(3,n+1)[0::2]) p = 3 i = 0 p = l[i] m = sqrt(n)+1 while p <= m: l = l[:i+1] + [n for n in l[i+1:] if n%p != 0] i += 1 p = l[i] return len(l) + 1 from sys import stdin for i in stdin: print(pm(int(i)))
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s355434033
p00009
Runtime Error
from math import sqrt def pm(n): l = list(range(3,n+1)[0::2]) p = 3 i = 0 p = l[i] m = sqrt(n)+1 while p <= m: l = l[:i+1] + [n for n in l[i+1:] if n%p != 0] i += 1 p = l[i] return len(l) + 1 from sys import stdin for i in stdin: print(pm(int(i)))
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s249847515
p00009
Runtime Error
from math import sqrt from sys import stdin def pm(n): l = list(range(3,n+1)[0::2]) p = 3 i = 0 p = l[i] m = sqrt(n)+1 while p <= m: l = l[:i+1] + [n for n in l[i+1:] if n%p != 0] i += 1 p = l[i] return len(l) + 1 for i in stdin: print(pm(int(i)))
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s702122212
p00009
Runtime Error
from math import sqrt from sys import stdin def pm(n): l = list(range(3,n+1)[0::2]) p = 3 i = 0 p = l[i] m = sqrt(n)+1 while p <= m: l = l[:i+1] + [n for n in l[i+1:] if n%p != 0] i += 1 p = l[i] return len(l) + 1 for n in stdin: print(pm(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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s317832388
p00009
Runtime Error
from math import sqrt from sys import stdin def pm(n): l = list(range(3,n+1)[0::2]) p = 3 i = 0 p = l[i] m = sqrt(n)+1 while p <= m: l = l[:i+1] + [n for n in l[i+1:] if n%p != 0] i += 1 p = l[i] return len(l) + 1 for n in stdin: print (pm(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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s423314266
p00009
Runtime Error
from math import sqrt from sys import stdin def pm(n): l = list(range(3,n+1)[0::2]) p = 3 i = 0 p = l[i] m = sqrt(n)+1 while p <= m: l = l[:i+1] + [n for n in l[i+1:] if n%p != 0] i += 1 p = l[i] return len(l) + 1 for n in stdin: print pm(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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s977949050
p00009
Runtime Error
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys LIMIT = 1000000 is_prime = [True for i in range(LIMIT+1)] p = 2 while p**2 <= LIMIT: if is_prime[p]: for i in range(p*2, n+1, p): is_prime[i] = False p += 1 for line in sys.stdin.readlines(): n = int(line.strip()) if n <= 1: print(0) continue if n == 2: print(1) continue num_prime = 1 for i in range(3, n+1): if is_prime[i]: num_prime += 1 print(num_prime)
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s207092529
p00009
Runtime Error
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys LIMIT = 1000000 is_prime = [True] * (LIMIT+1) p = 2 while p**2 <= LIMIT: if is_prime[p]: for i in range(p*2, n+1, p): is_prime[i] = False p += 1 for line in sys.stdin.readlines(): n = int(line.strip()) if n <= 1: print(0) continue if n == 2: print(1) continue num_prime = 1 for i in range(3, n+1): if is_prime[i]: num_prime += 1 print(num_prime)
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s174888183
p00009
Runtime Error
import math import sys a = [] # create an array to save input integers for line in sys.stdin: a.append(int(line)) def is_prime(n): if n == 1: return False for i in range(2, int(math.sqrt(n) + 1)): if n % i == 0: return False return True ans = [0] for i in range(1, 100000): if is_prime(i): ans.append(ans[-1] + 1) else: ans.append(ans[-1]) for i in a: print ans[i]
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s673487810
p00009
Runtime Error
import sys import math as mas def sieve(n): p=[True for i in range(n+1)] p[0]=p[1]=False end=int(n**0.5) for i in range(2,end+1): if p[i]: for j in range(i*i,n+1,i): p[j]=False return p sosu=sieve(1000010) for i in sys.stdin: print(sum(sosu[t] for t in range(int(i))) # a,b=map(int,i.split()) # print(gcd(a,b),lcm(a,b))
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s929107196
p00009
Runtime Error
from itertools import takewhile primes = [2, 3, 5, 7] append_prime = primes.append upper = 10 def is_prime(num): for p in primes: if num % p == 0: return False return True def calc_prime(num): for i in range(upper + 1, num + 1): if is_prime(i): append_prime(i) for s in sys.stdin: print(primes) n = int(s) if upper < n: calc_prime(n) upper = n print(len(primes)) else: print(len(tuple(takewhile(lambda x: x <= n, primes))))
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s217176712
p00009
Runtime Error
# -*- coding: utf-8 -*- import sys import os import math def Eratosthenes(n): lst = [i for i in range(2, n+1)] primes = [] sqrt_n = n ** 0.5 while True: first = lst.pop(0) if first < sqrt_n: primes.append(first) new_lst = [] for v in lst: if v % first != 0: new_lst.append(v) lst = new_lst else: # ?????? return primes + [first] + lst if __name__ == '__main__': inputs = sys.stdin.readlines() for s in inputs: n = int(s) lst = Eratosthenes(n) print(len(lst))
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s802688993
p00009
Runtime Error
# -*- coding: utf-8 -*- import sys import os import math def Eratosthenes(n): lst = [i for i in range(2, n+1)] primes = [] sqrt_n = n ** 0.5 while True: first = lst.pop(0) if first < sqrt_n: primes.append(first) new_lst = [] for v in lst: if v % first != 0: new_lst.append(v) lst = new_lst else: # ?????? return primes + [first] + lst inputs = sys.stdin.readlines() for s in inputs: n = int(s) lst = Eratosthenes(n) print(len(lst))
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s553824456
p00009
Runtime Error
# -*- coding: utf-8 -*- import sys import os import math def Eratosthenes(n): lst = [i for i in range(2, n+1)] primes = [] sqrt_n = n ** 0.5 while True: first = lst.pop(0) if first < sqrt_n: primes.append(first) new_lst = [] for v in lst: if v % first != 0: new_lst.append(v) lst = new_lst else: # ?????? return primes + [first] + lst s_list = sys.stdin.readlines() for s in s_list: n = int(s) lst = Eratosthenes(n) print(len(lst))
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s448153442
p00009
Runtime Error
# -*- coding: utf-8 -*- import sys import os import math def eratosthenes(n): lst = [i for i in range(2, n+1)] primes = [] sqrt_n = n ** 0.5 while True: first = lst.pop(0) if first < sqrt_n: primes.append(first) new_lst = [] for v in lst: if v % first != 0: new_lst.append(v) lst = new_lst else: # ?????? return primes + [first] + lst for s in sys.stdin: n = int(s) lst = eratosthenes(n) print(len(lst))
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s160253634
p00009
Runtime Error
# -*- coding: utf-8 -*- import sys import os import math def eratosthenes(n): lst = [i for i in range(2, n+1)] primes = [] sqrt_n = n ** 0.5 while lst: first = lst.pop(0) if first < sqrt_n: primes.append(first) new_lst = [] for v in lst: if v % first != 0: new_lst.append(v) lst = new_lst else: # ?????? return primes + [first] + lst for s in sys.stdin: n = int(s) lst = eratosthenes(n) print(len(lst))
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s143769283
p00009
Runtime Error
# -*- coding: utf-8 -*- import sys import os import math def eratosthenes(n): lst = [i for i in range(2, n+1)] primes = [] sqrt_n = math.sqrt(n) while lst: first = lst.pop(0) if first < sqrt_n: primes.append(first) new_lst = [] for v in lst: if v % first != 0: new_lst.append(v) lst = new_lst else: # ?????? return primes + [first] + lst for s in sys.stdin: n = int(s) lst = eratosthenes(n) print(len(lst))
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s504652410
p00009
Runtime Error
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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s800299390
p00009
Runtime Error
if __name__ == '__main__': while True: n = int(input()) is_prime = [True for i in range(n + 1)] is_prime[0] = False is_prime[1] = False p = 0 for i in range(2, n + 1): if is_prime[i]: p += 1 for j in range(i * 2, n + 1, i): is_prime[j] = False print(p)
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s480749878
p00009
Runtime Error
while True: n = int(input()) is_prime = [True for i in range(n + 1)] is_prime[0] = False is_prime[1] = False p = 0 for i in range(2, n + 1): if is_prime[i]: p += 1 for j in range(i * 2, n + 1, i): is_prime[j] = False print(p)
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s397643375
p00009
Runtime Error
import sys def main(): for _ in range(30): try: number = int(sys.stdin) 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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s375475650
p00009
Runtime Error
import sys; import math; lines = str(sys.stdin.read()).strip().split("\n") for line in lines: line = int(line) pList = [] sList = list(reversed(list(range(3, line + 1))[::2])) while sList[-1] < math.ceil(math.sqrt(line)) + 1 : pList.append(sList.pop()) for p in pList: sList = list(filter(lambda i: i % p != 0, sList)) print(len(sList) + len(pList) + 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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s075684022
p00009
Runtime Error
import sys import math lines = str(sys.stdin.read()).strip().split("\n") for line in lines: line = int(line) pList = [] sList = list(reversed(list(range(3, line + 1))[::2])) while sList[-1] < math.ceil(math.sqrt(line)) + 1 : pList.append(sList.pop()) for p in pList: sList = list(filter(lambda i: i % p != 0, sList)) print(len(sList) + len(pList) + 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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s437799286
p00009
Runtime Error
import sys import math lines = str(sys.stdin.read()).strip().split("\n") for line in lines: line = int(line) pList = [] sList = list(reversed(list(range(3, line + 1))[::2])) while sList[-1] < int(math.ceil(math.sqrt(line))) + 1 : pList.append(sList.pop()) for p in pList: sList = list(filter(lambda i: i % p != 0, sList)) pList.extend(sList) pList.append(2) print(len(pList))
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s606762120
p00009
Runtime Error
import sys import math lines = str(sys.stdin.read()).strip().split("\n") for line in lines: line = int(line) pList = [] sList = list(reversed(list(range(3, line + 1))[::2])) while sList[-1] < int(math.ceil(math.sqrt(line))) + 1: pList.append(sList.pop()) for p in pList: sList = list(filter(lambda i: i % p != 0, sList)) pList.extend(sList) pList.append(2) print(len(pList))
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s211159804
p00009
Runtime Error
import sys import math lines = str(sys.stdin.read()).strip().split("\n") for line in lines: line = int(line) pList = [] sList = list(reversed(list(range(3, line + 1))[::2])) while sList[-1] < (int(math.ceil(math.sqrt(line))) + 1): pList.append(sList.pop()) for p in pList: sList = list(filter(lambda i: i % p != 0, sList)) pList.extend(sList) pList.append(2) print(len(pList))
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s779529091
p00009
Runtime Error
import math 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: n = int(input()) 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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s091456248
p00009
Runtime Error
#coding:utf-8 import time import math import numpy as np 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 x = int(input()) r_list = list(range(2,(x+1))) ans = [] ans = Eratos(r_list) print("prime numbers is ") 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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s297726822
p00009
Runtime Error
#coding:utf-8 import time import math import numpy as np 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 x = int(input()) 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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s708756566
p00009
Runtime Error
#coding:utf-8 import time import math import numpy as np 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 x = int(input()) 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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s417745086
p00009
Runtime Error
import sys import math import array from array M = 1000000 B = int(math.sqrt(M)+1)//6+1 N = M//6 N1 = N+1 if M % 6 == 5 else N N2 = N+1 if M % 6 >= 1 else N l = array('I',[1]) * N1 m = array('I',[1]) * N2 i = 5 ini = 4 for p in range(B): if l[p] == 1: l[p+i::i] = [0] * len(l[p+i::i]) m[ini-1::i] = [0] * len(m[ini-1::i]) if m[p] == 1: m[p+i+2::i+2] = [0] * len(m[p+i+2::i+2]) l[ini+1::i+2] = [0] * len(l[ini+1::i+2]) i += 6 ini += 5 for i in sys.stdin: n = int(i) r = n-1 if n < 3 else sum(l[0:(n+1)//6])+sum(m[0:(n-1)//6])+2 print(r)
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s706491600
p00009
Runtime Error
import sys import math from array import array M = 1000000 B = int(math.sqrt(M)+1)//6+1 N = M//6 N1 = N+1 if M % 6 == 5 else N N2 = N+1 if M % 6 >= 1 else N l = array('I',[1]) * N1 m = array('I',[1]) * N2 i = 5 ini = 4 for p in range(B): if l[p] == 1: l[p+i::i] = [0] * len(l[p+i::i]) m[ini-1::i] = [0] * len(m[ini-1::i]) if m[p] == 1: m[p+i+2::i+2] = [0] * len(m[p+i+2::i+2]) l[ini+1::i+2] = [0] * len(l[ini+1::i+2]) i += 6 ini += 5 for i in sys.stdin: n = int(i) r = n-1 if n < 3 else sum(l[0:(n+1)//6])+sum(m[0:(n-1)//6])+2 print(r)
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s875245773
p00009
Runtime Error
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,math.sqrt(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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s621684000
p00009
Runtime Error
import itertools import math import sys ?? MAX = 999999 ?? ?? def sieve_of_eratosthenes(max): ????????is_prime = [True] * (max + 1) ????????is_prime[0] = False ????????is_prime[1] = False ????????for i in range(2, int(math.sqrt(max)) + 1): ????????????????if not is_prime[i]: ????????????????????????continue ????????????????for j in range(i * i, max + 1, i): ????????????????????????is_prime[j] = False ????????return filter(lambda x: is_prime[x], range(max + 1)) ?? ?? def main(): ????????p = list(sieve_of_eratosthenes(MAX)) ????????for l in sys.stdin: ????????????????n = int(l) ????????????????print(len(list(itertools.takewhile(lambda x: x <= n, p)))) ?? ?? 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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s943971620
p00009
Runtime Error
t = 0 while t == 0: total = 0 try: n = int(input()) except: break else: if n <= 1: else: for a in range(2,n): if n % a == 0: break total += 1 print(total)
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s352631614
p00009
Runtime Error
while t == 0: total = 0 try: n = int(input()) except: break else: if n <= 1: else: for a in range(2,n): if n % a == 0: break break total += 1 print(total)
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s027414281
p00009
Runtime Error
while t == 0: total = 0 try: n = int(input()) except: break else: print(total)
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s222638203
p00009
Runtime Error
while t == 0: total = 0 try: n = int(input()) except: break else: print(total)
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s719325391
p00009
Runtime Error
while t == 0: total = 0 try: n = int(input()) except: break else: print(total)
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s646452472
p00009
Runtime Error
t = 0 while t == 0: total = 0 try: n = int(input()) except: break else: if n <= 1: else: for a in range(2,n): if n % a == 0: break break total += 1 print(total)
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s419345428
p00009
Runtime Error
t = 0 while t == 0: prime = [2] try: n = int(input()) except: break #?¨??????\???????????????????¨???? else: if n == 1: #1????????? 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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s645769568
p00009
Runtime Error
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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s819375801
p00009
Runtime Error
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 while t == 0: try: x = int(input().split()) except: break else: n = 1 if x == 0 or 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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s446732996
p00009
Runtime Error
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 while 1: print(prime_count(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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s053964938
p00009
Runtime Error
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 while 1: n=input() if not n:break 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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s828173659
p00009
Runtime Error
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 while 1: print(prime_count(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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s598761139
p00009
Runtime Error
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_2(int(n)))
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s312739487
p00009
Runtime Error
import sys for line im sys.stdin: lis = [] if line >= 2: lis.append(2) if line >= 3: lis.append(3) if line >= 5: for i in xrange(5,line+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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s215598740
p00009
Runtime Error
import sys N = 999999 lis = [] if N >= 2: lis.append(2) if N >= 3: lis.append(3) if N >= 5: for i in xrange(5,N+1,2): for item in lis: if item > (i**0.5): lis.append(i) break if i % item == 0: break else: lis.append(i) dp = [0]*999999 for item in lis: dp[item-1] += 1 for i in xrange(1,999999): dp[i] += dp[i-1] for line in sys.stdin: num = int(line) print dp[line-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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s297903385
p00009
Runtime Error
IsPrimes = [True] * 1000002 IsPimes[0], IsPimes[1] = False, False for i in range(2, 1001): if IsPrime[i]: for j in range(i*i, 1000001, i) IsPrime[j]= False cnt = [0] * 1000001 for i in range(1000001): if IsPimes[i]: cnt[i] += 1 for i in range(1, 1000001): cnt[i] += cnt[i-1] while True: try: n = int(raw_input()) print cnt[n] except EOFError: break
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s019762875
p00009
Runtime Error
import sys m=10**6;a=[1]*m;a[0:2]=0,0 for i in range(2,999): if a[i]>0: for j in range(i*2,,i):a[j]=0 for i in range(m):a[i]+=a[i-1] for e in sys.stdin:print(a[int(e)])
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s282135630
p00009
Runtime Error
m=10*6;a=[0]+[1]*m for i in range(999): if a[i]:a[i*2+1::i+1]=[0 for e in range(len(li[i*2+1::i+1]))] for e in sys.stdin:print(len([i for i in li[:int(e)]if i]))
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s255006453
p00009
Runtime Error
import sys a=[0,0]+[1]*10**6 for i in range(999): if a[i]: for j in range(i*2,m,i):a[j]=0 for e in sys.stdin:print(sum(a[:int(e)+1]))
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s492396062
p00009
Runtime Error
a=[0]+[1]*10*6 for i in range(999): if a[i]: a[i*2+1::i+1]=[0 for e in range(len(li[i*2+1::i+1]))] for e in sys.stdin:print(len([i for i in li[:int(e)]if i]))
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s942031427
p00009
Runtime Error
import sys a=[0,0]+[1]*10**6 for i in range(999): if a[i]:a[i*2::i]=[0 for j in a[i*2::i]] for e in sys.stdin:print(len([i for i in li[:int(e)+1]if i]))
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s482431986
p00009
Runtime Error
import sys a=[0,0]+[1]*10**6 for i in range(999): if a[i]:a[i*2::i]=[0 for j in a[i*2::i]] for e in sys.stdin:print(int(e)-len([i for i in li[:int(e)+1]if i]))
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s158467700
p00009
Runtime Error
import sys a=[1]*500000 for i in range(3,999,2): x=i*i;if a[i]:a[x//2::i]=[0]*len(a[x//2::i]) for e in map(int,sys.stdin):print([e-1,sum(a[:(e+1)//2])+1][e>4])
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s088128215
p00009
Runtime Error
import sys m=166666;s=[1]*m;t=[1]*m for i in range(m): for j in range(2): if (s[i],t[i])[j]: k=6*i+[5,7][j];n=[i+k,k-i-2] s[n[i]::k]=[0]*len(s[n[i]::k]) t[n[1-i]::k]=[0]*len(t[n[1-i]::k]) for e in map(int,sys.stdin): print([e-1,sum(s[:(e+1)//6])+sum(t[:(e-1)//6])+2)[e>3])
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s965507468
p00009
Runtime Error
import sys m=166666;s=[1]*m;t=[1]*m for i in range(m): for j in range(2): if (s[i],t[i])[j]: k=6*i+[5,7][j];n=[i+k,k-i-2] s[n[i]::k]=[0]*len(s[n[i]::k]) t[n[1-i]::k]=[0]*len(t[n[1-i]::k]) for e in map(int,sys.stdin): print([e-1,sum(s[:(e+1)//6])+sum(t[:(e-1)//6])+2][e>3])
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s342927557
p00009
Runtime Error
import sys a=[1]*500000 [a[(i*i)//2::i]=[0]*len(a[(i*i)//2::i])for i in range(3,999,2)if a[i//2]] [print([e-1,sum(a[:(e+1)//2])][e>3])for e in map(int,sys.stdin)]
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s137944100
p00009
Runtime Error
from sys import stdin def isprime(n): from math import floor,sqrt if n <= 1: return False for i in range(2,floor(sqrt(n))+1): if n % i == 0: return False return True N = [] for line in stdin: N.append(int(line)) for i in N: ans = 0 for j in i: if isprime(j): ans += 1 print(ans)
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s579411616
p00009
Runtime Error
import math def Eratos(n): primes = [2] if n % 2 == 0: num = [2*i+1 for i in range(1,n/2)] else: num = [2*i+1 for i in range(1,(n+1)/2)] tmp = [] top = 1 while top < math.sqrt(n): top = num[0] for i in range(1,len(num)): if num[i] % top != 0: tmp.append(num[i]) num = tmp tmp = [] primes.append(top) for i in range(len(num)): primes.append(num[i]) return primes def list_count(list_a,n): cont = 0 for i in range(len(list_a)): if list_a[i] > n: break else: cont += 1 return cont primes = Eratos(1000000) while True: try: n = int(input()) print(list_count(primes,n)) except EOFError: break
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s001944014
p00009
Runtime Error
import math while True: try: r = int(input()) A = [i for i in range(2, r+1)] P = [] time = 0 while True: prime = min(A) if prime > math.sqrt(r): break P.append(prime) i = 0 while i < len(A): if A[i] % prime == 0: A.pop(i) continue i += 1 for a in A: P.append(a) print(len(P)) 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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s876875249
p00009
Runtime Error
import math try: while True: r = int(input()) A = [i for i in range(2, r+1)] P = [] time = 0 while True: prime = min(A) if prime > math.sqrt(r): break P.append(prime) i = 0 while i < len(A): if A[i] % prime == 0: A.pop(i) continue i += 1 for a in A: P.append(a) print(len(P)) except EOFError: pass
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s587287846
p00009
Runtime Error
import numpy as np while 1: num = int(input()) n = [] #素数をかくのするためのリスト li = [] #2から入力された値までのすべての数を格納するリスト #2から入力された値までのすべての数を格納 li = [i for i in range(2,num+1)] #liリストの0番目が入力された値の平方根以下になるまでloop while li[0] <= int(np.sqrt(num)): n.append(li[0]) #nリストにliリストの0番目を追加 sss = li[0] #sssにliリストの0番目を格納 li = [i for i in li if i % sss != 0] #素数判定 n.extend(li) #liリストに残った数を素数としてnリストに格納 print(len(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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s013273600
p00009
Runtime Error
def prime_calc(n): if n < 2: return 0 else: i = 2 while i*i <= n: if n % i == 0: return 0 else: i = i + 1 return 1 def prime(n): cnt = 0 for i in range(1, n+1): ans = prime_calc(i) if ans == 1: cnt = cnt + 1 return cnt def main(): l = [] for line in sys.stdin: l.append(int(line)) for line in l: print(prime(line)) 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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s474841358
p00009
Runtime Error
import argparser def prime_calc(n): if n < 2: return 0 else: i = 2 while i*i <= n: if n % i == 0: return 0 else: i = i + 1 return 1 def prime(n): cnt = 0 for i in range(1, n+1): ans = prime_calc(i) if ans == 1: cnt = cnt + 1 return cnt def main(): l = [] parser = argparse.ArgumentParser() parser.add_argument("filename", help="The filename to be processed") args = parser.parse_args() if args.filename: with open(args.filename) as f: for line in f: a = int(line.rstrip()) l.append(a) for line in l: print(prime(line)) 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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s634828564
p00009
Runtime Error
import argparse def prime_calc(n): if n < 2: return 0 else: i = 2 while i*i <= n: if n % i == 0: return 0 else: i = i + 1 return 1 def prime(n): cnt = 0 for i in range(1, n+1): ans = prime_calc(i) if ans == 1: cnt = cnt + 1 return cnt def main(): l = [] parser = argparse.ArgumentParser() parser.add_argument("filename", help="The filename to be processed") args = parser.parse_args() if args.filename: with open(args.filename) as f: for line in f: a = int(line.rstrip()) l.append(a) for line in l: print(prime(line)) 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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s985793080
p00009
Runtime Error
import sys def prime_calc(n): if n < 2: return False else: i = 2 while n > i: if n % i == 0: return False else: i += 1 return True def prime(n): cnt = 0 for i in range(0, n+1): ans = prime_calc(i) if ans is True: cnt = cnt + 1 return cnt def main(): a = [] for line in sys.stdin: a.append(int(line)) for line in l: print(prime(line)) 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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s169277116
p00009
Runtime Error
import def prime_calc(n): if n < 2: return False else: i = 2 while n > i: if n % i == 0: return False else: i += 1 return True def prime(n): cnt = 0 for i in range(0, n+1): ans = prime_calc(i) if ans is True: cnt = cnt + 1 return cnt def main(): a = [] for line in sys.stdin: a.append(int(line)) for line in a: print(prime(line)) 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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s139759054
p00009
Runtime Error
import argparse def prime_calc(n): if n < 2: return False else: i = 2 while n > i: if n % i == 0: return False else: i += 1 return True def prime(n): cnt = 0 for i in range(0, n+1): ans = prime_calc(i) if ans is True: cnt = cnt + 1 return cnt def main(): l = [] parser = argparse.ArgumentParser() parser.add_argument("filename", help="The filename to be processed") args = parser.parse_args() if args.filename: with open(args.filename) as f: for line in f: a = int(line.rstrip()) l.append(a) for line in l: print(prime(line)) 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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s350167879
p00009
Runtime Error
t =[] for n in range(2,10000): for x in range(2,n): if n % x == 0: break else: t.append(n) while True: try: b=0 a = int(input()) for b in range(10000): if t[b] > a: print len(t[0:b]) 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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s133269875
p00009
Runtime Error
t = [] for a in range(2,10000): for n in range(2,a): if a % n == 0: break else: t.append(a) while True: try: z = int(input()) for w in range(1000000): if t[w] > z: break print len(t[0:w]) 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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s678806407
p00009
Runtime Error
t =[] for n in range(2,10000): for x in range(2,n): if n % x == 0: break else: t.append(n) while True: try: a = int(input()) for b in range(100000): if t[b] >= a: break print len((t[0:b])) 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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s575702993
p00009
Runtime Error
# -*- coding: utf-8 -*- while True: try: n = int(raw_input()) list1 = range(2, n) list2 = [] while True: i = list1.pop(0) list2.append(i) for x in list1: if x % i == 0: list1.remove(x) if i**2 > list1[::-1][0]: break print(len(list2 + list1)) 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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s637527336
p00009
Runtime Error
# -*- coding: utf-8 -*- while True: try: n = int(raw_input()) if n < 3: print(0) continue list1 = range(2, n) list2 = [] while True: i = list1.pop(0) list2.append(i) for x in list1: if x % i == 0: list1.remove(x) if i**2 > list1[::-1][0]: break print(len(list2 + list1)) 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 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s991199099
p00009
Runtime Error
import sys n=10**5 s=[True]*n s[0]=False s[1]=False for x in xrange(2, int(n**0.5)+1): if s[x]: for i in xrange(x+x,n,x): s[i]=False for x in sys.stdin.readlines(): x=int(x) cnt=0 for i in xrange(x): if s[i]: cnt=cnt+1 print cnt
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s477330240
p00009
Runtime Error
import sys n=10**5 s=[True]*n s[0]=False s[1]=False for x in xrange(2, int(n**0.5)+1): if s[x]: for i in xrange(x+x,n,x): s[i]=False for x in sys.stdin.readlines(): a=int(x) cnt=0 for i in xrange(a): if s[i]: cnt=cnt+1 print cnt
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
s417080556
p00009
Runtime Error
import sys n=10**5+1 s=[True]*n s[0]=False s[1]=False for x in xrange(2, int(n**0.5)+1): if s[x]: for i in xrange(x+x,n,x): s[i]=False for x in sys.stdin.readlines(): a=int(x) cnt=0 for i in xrange(a): if s[i]: cnt=cnt+1 print cnt
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>