結果

問題 No.1657 Sum is Prime (Easy Version)
ユーザー SidewaysOwl
提出日時 2021-08-27 22:09:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 418 ms / 2,000 ms
コード長 477 bytes
コンパイル時間 159 ms
コンパイル使用メモリ 82,620 KB
実行使用メモリ 143,808 KB
最終ジャッジ日時 2024-11-21 02:40:41
合計ジャッジ時間 10,528 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

l = [0] * (10 ** 7 + 1)
l[1]= 1
for i in range(2,int((10 ** 7) ** (1/2)) + 1):
    if l[i] == 0:
        n = i  * 2
        cnt = 2
        while n <= 10 ** 7:
            l[n] = 1
            cnt += 1
            n = i * cnt
L,R = map(int,input().split())
ans = 0
for i in range(1,10 ** 7 + 1):
    if L<= i <= R:
        if l[i] == 0:
            ans += 1
    if l[i] == 0:
        if i & 1:
            if L <= (i-1)//2 and (i+1)//2 <= R:
                ans += 1
print(ans)
0