結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー 👑 KazunKazun
提出日時 2020-11-13 16:14:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 290 ms / 1,000 ms
コード長 765 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 87,264 KB
実行使用メモリ 140,720 KB
最終ジャッジ日時 2023-09-30 02:08:43
合計ジャッジ時間 5,148 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,136 KB
testcase_01 AC 69 ms
71,356 KB
testcase_02 AC 69 ms
71,372 KB
testcase_03 AC 78 ms
77,452 KB
testcase_04 AC 73 ms
71,436 KB
testcase_05 AC 68 ms
71,316 KB
testcase_06 AC 68 ms
71,212 KB
testcase_07 AC 68 ms
71,488 KB
testcase_08 AC 68 ms
71,472 KB
testcase_09 AC 68 ms
71,388 KB
testcase_10 AC 70 ms
71,272 KB
testcase_11 AC 72 ms
71,604 KB
testcase_12 AC 69 ms
71,656 KB
testcase_13 AC 69 ms
71,332 KB
testcase_14 AC 72 ms
75,532 KB
testcase_15 AC 70 ms
71,656 KB
testcase_16 AC 71 ms
71,408 KB
testcase_17 AC 69 ms
71,316 KB
testcase_18 AC 69 ms
71,508 KB
testcase_19 AC 91 ms
82,364 KB
testcase_20 AC 124 ms
95,024 KB
testcase_21 AC 68 ms
71,408 KB
testcase_22 AC 69 ms
71,460 KB
testcase_23 AC 70 ms
71,472 KB
testcase_24 AC 69 ms
71,432 KB
testcase_25 AC 177 ms
107,756 KB
testcase_26 AC 74 ms
71,508 KB
testcase_27 AC 73 ms
71,456 KB
testcase_28 AC 75 ms
71,432 KB
testcase_29 AC 74 ms
71,208 KB
testcase_30 AC 70 ms
71,632 KB
testcase_31 AC 68 ms
71,456 KB
testcase_32 AC 115 ms
91,856 KB
testcase_33 AC 290 ms
140,652 KB
testcase_34 AC 273 ms
140,720 KB
testcase_35 AC 151 ms
105,636 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#エラトステネスの篩
def Sieve_of_Eratosthenes(N,mode=False):
    """Nまでのエラトステネスの篩を実行

    N:自然数
    mode:False->素数のリスト,True->素数かどうかのリスト
    (False->[2,3,5,...],True->[False,False,True,True,False,True,...])
    """

    T=[True]*(N+1)
    T[0]=T[1]=0
    a=2
    while a*a<=N:
        if T[a]:
            b=a*a
            while b<=N:
                T[b]=False
                b+=a
        a+=1

    if mode:
        return T
    else:
        return [k for k in range(N+1) if T[k]]

#================================================
N,L=map(int,input().split())

if 2*(N-1)>L:
    print(0)
    exit()

D=Sieve_of_Eratosthenes(L//(N-1),False)

X=0
for d in D:
    X+=L-(N-1)*d+1
print(X)
0