Submission #1926394


Source Code Expand

Copy
import math
def is_prime(n):
    if n < 2:
        return False
    if n == 2:
        return True
    if n%2 == 0:
        return False
    for i in xrange(3, int(math.sqrt(n))+1, 2):
        if n%i == 0:
            return False
    return True

m = list()
s = 0
for i in xrange(10**5):
    if is_prime(i) and is_prime((i+1)/2):
        s += 1
    m.append(s)

n = input()
for _ in xrange(n):
    s = 0
    a, b = map(int, raw_input().split())
    print m[b] - m[a-1]

Submission Info

Submission Time
Task D - 2017-like Number
User pikachu1101
Language Python (2.7.6)
Score 400
Code Size 495 Byte
Status AC
Exec Time 497 ms
Memory 3948 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 10
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
01.txt AC 467 ms 3948 KB
02.txt AC 467 ms 3948 KB
03.txt AC 476 ms 3948 KB
04.txt AC 466 ms 3948 KB
05.txt AC 451 ms 3948 KB
06.txt AC 497 ms 3948 KB
07.txt AC 496 ms 3820 KB
sample_01.txt AC 161 ms 3564 KB
sample_02.txt AC 147 ms 3564 KB
sample_03.txt AC 147 ms 3564 KB