結果

問題 No.1657 Sum is Prime (Easy Version)
ユーザー teepeeteeteepeetee
提出日時 2021-09-03 08:40:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 638 ms / 2,000 ms
コード長 480 bytes
コンパイル時間 252 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 219,836 KB
最終ジャッジ日時 2024-05-08 07:49:31
合計ジャッジ時間 5,898 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
52,096 KB
testcase_01 AC 47 ms
52,224 KB
testcase_02 AC 513 ms
193,752 KB
testcase_03 AC 46 ms
52,096 KB
testcase_04 AC 43 ms
52,096 KB
testcase_05 AC 41 ms
52,096 KB
testcase_06 AC 60 ms
63,104 KB
testcase_07 AC 54 ms
60,416 KB
testcase_08 AC 55 ms
60,800 KB
testcase_09 AC 55 ms
60,928 KB
testcase_10 AC 57 ms
61,184 KB
testcase_11 AC 66 ms
64,640 KB
testcase_12 AC 497 ms
208,156 KB
testcase_13 AC 248 ms
136,320 KB
testcase_14 AC 346 ms
146,084 KB
testcase_15 AC 320 ms
169,200 KB
testcase_16 AC 135 ms
112,768 KB
testcase_17 AC 112 ms
92,416 KB
testcase_18 AC 133 ms
102,272 KB
testcase_19 AC 484 ms
196,796 KB
testcase_20 AC 237 ms
148,288 KB
testcase_21 AC 638 ms
219,836 KB
testcase_22 AC 195 ms
115,200 KB
testcase_23 AC 229 ms
133,632 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

l,r=map(int,input().split())
lis=[]
for i in range(l,r+1):
    lis.append((i,i))
    if i < r+1:
        lis.append((i,i+1))
n= r+r

sosu=[i for i in range(n+1) ]
for i in range(4,n+1,2):
    sosu[i]=0
for j in range(3,int(n**0.5)+1,2):
    for k in range(j,n//j+1,2):
        sosu[j*k]=0
        
set_p=set(sosu[2:])
ans=0

for i,j in lis:
    if i == j :
        if i in set_p:
            ans+=1            
    else:
        if i+j in set_p:
            ans+=1
print(ans)
    
0