結果

問題 No.843 Triple Primes
ユーザー yansi819
提出日時 2024-05-12 17:45:04
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 423 bytes
コンパイル時間 200 ms
コンパイル使用メモリ 81,576 KB
実行使用メモリ 149,044 KB
最終ジャッジ日時 2024-12-20 09:11:43
合計ジャッジ時間 73,891 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 TLE * 1
other AC * 19 WA * 2 TLE * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

def primes(N):
    #N = 5 * (10 ** 5)
    res = []
    isprime = [True] * (N + 1)
    isprime[0] = isprime[1] = False
    for i in range(2, N + 1):
        if isprime[i]:
            res.append(i)
            for j in range(i * 2, N + 1, i):
                isprime[j] = False
    return res

N = int(input())
P = primes(N)
#print(len(P))
ans = 0
for q in P:
    if (q + 2) ** 0.5 in P:
        ans += 1
print(ans * 2 - 1)
0