Submission #2123697
Source Code Expand
import math Q = int(input()) li = [] M = 0 for index in range(Q): l, r = map(int, input().split()) li.append((l, r)) M = max([M, l, r]) primes = list(range(M+1)) primes[0] = 0 primes[1] = 0 cut_root = math.sqrt(M+1) for prime in primes: if prime > cut_root: break if prime == 0: continue for non_prime in range(2 * prime, M, prime): primes[non_prime] = 0 similar_2017 = [0 for _ in range(M+1)] similar_2017[3] = 1 for i in range(5, M+1, 4): if primes[i] != 0: if primes[(i+1)//2] != 0: similar_2017[i] = 1 for l, r in li: print(sum(similar_2017[l:r+1]))
Submission Info
Submission Time | |
---|---|
Task | D - 2017-like Number |
User | attachecase |
Language | Python (3.4.3) |
Score | 0 |
Code Size | 604 Byte |
Status | TLE |
Exec Time | 2105 ms |
Memory | 22736 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 400 | ||||||
Status |
|
|
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 | TLE | 2105 ms | 22668 KB |
02.txt | TLE | 2105 ms | 22456 KB |
03.txt | TLE | 2105 ms | 22736 KB |
04.txt | TLE | 2105 ms | 22660 KB |
05.txt | TLE | 2105 ms | 18896 KB |
06.txt | TLE | 2105 ms | 20596 KB |
07.txt | TLE | 2105 ms | 22324 KB |
sample_01.txt | AC | 17 ms | 3064 KB |
sample_02.txt | AC | 18 ms | 3064 KB |
sample_03.txt | AC | 17 ms | 3064 KB |