結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー ThetaTheta
提出日時 2022-11-25 17:01:03
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 619 bytes
コンパイル時間 406 ms
コンパイル使用メモリ 82,100 KB
実行使用メモリ 78,124 KB
最終ジャッジ日時 2024-04-09 23:26:00
合計ジャッジ時間 5,347 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
59,808 KB
testcase_01 AC 35 ms
53,604 KB
testcase_02 AC 36 ms
53,232 KB
testcase_03 TLE -
testcase_04 AC 35 ms
53,132 KB
testcase_05 AC 35 ms
51,956 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 36 ms
52,496 KB
testcase_10 WA -
testcase_11 AC 35 ms
53,116 KB
testcase_12 AC 35 ms
52,612 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 35 ms
53,064 KB
testcase_16 AC 37 ms
52,124 KB
testcase_17 WA -
testcase_18 AC 35 ms
53,284 KB
testcase_19 TLE -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import ceil


def calc_prime_numbers(upper: int) -> list[int]:
    prime_numbers = []
    for number in range(2, upper+1):
        for prime in prime_numbers:
            if number % prime == 0:
                break
        else:
            prime_numbers.append(number)
    return prime_numbers


def main():
    N, L = map(int, input().split())
    interval_upper = ceil(L/(N-1))
    interval_candidate = calc_prime_numbers(interval_upper)

    patterns = 0
    for interval in interval_candidate:
        patterns += L - interval * (N - 1) + 1

    print(patterns)


if __name__ == "__main__":
    main()
0