結果

問題 No.192 合成数
ユーザー TakoKurageTakoKurage
提出日時 2020-02-24 16:40:53
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 425 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-10-12 05:18:55
合計ジャッジ時間 2,252 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

def primes(n):
    memo = [True] * (n + 1)
    i = 2
    while i * i <= n:
        if memo[i]:
            j = i << 1
            while j <= n:
                memo[j] = False
                j += i
        i += 1
    return {i for i in range(n + 1) if memo[i] and i >= 2}


N = int(input())

P = primes(N + 100)

l, r = N - 100, N + 100
for i in range(l, r + 1):
    if i != 1 and i not in P:
        print(i)
        quit()
0