結果

問題 No.1657 Sum is Prime (Easy Version)
ユーザー ntudantuda
提出日時 2021-08-28 17:00:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,887 ms / 2,000 ms
コード長 502 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 87,340 KB
実行使用メモリ 262,160 KB
最終ジャッジ日時 2023-08-14 03:08:53
合計ジャッジ時間 20,380 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,744 KB
testcase_01 AC 73 ms
71,596 KB
testcase_02 AC 1,827 ms
261,128 KB
testcase_03 AC 71 ms
71,532 KB
testcase_04 AC 72 ms
71,780 KB
testcase_05 AC 71 ms
71,824 KB
testcase_06 AC 81 ms
76,568 KB
testcase_07 AC 77 ms
76,128 KB
testcase_08 AC 76 ms
76,264 KB
testcase_09 AC 79 ms
76,076 KB
testcase_10 AC 81 ms
76,032 KB
testcase_11 AC 84 ms
76,752 KB
testcase_12 AC 1,791 ms
260,304 KB
testcase_13 AC 923 ms
259,120 KB
testcase_14 AC 1,499 ms
260,388 KB
testcase_15 AC 1,544 ms
260,500 KB
testcase_16 AC 644 ms
217,272 KB
testcase_17 AC 755 ms
241,516 KB
testcase_18 AC 840 ms
257,916 KB
testcase_19 AC 1,674 ms
260,956 KB
testcase_20 AC 1,113 ms
259,544 KB
testcase_21 AC 1,887 ms
262,160 KB
testcase_22 AC 1,826 ms
261,608 KB
testcase_23 AC 1,815 ms
260,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

L,R = map(int,input().split())

def seachPrimeNum(N):
    max = int(N**0.5)
    seachList = [i for i in range(2,N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum

P = set(seachPrimeNum(2*R))
ans = 0
for i in range(L,R):
    if i in P:
        ans += 1
    if 2*i+1 in P:
        ans += 1
if R in P:
    ans += 1
print(ans)
0