結果
問題 | No.843 Triple Primes |
ユーザー |
![]() |
提出日時 | 2021-01-07 10:37:16 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 649 bytes |
コンパイル時間 | 315 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 90,368 KB |
最終ジャッジ日時 | 2024-11-08 00:13:18 |
合計ジャッジ時間 | 6,004 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 38 WA * 4 |
ソースコード
def sieve(n):is_prime = [True for _ in range(n+1)]is_prime[0] = Falsefor i in range(2, n+1):if is_prime[i-1]:j = 2 * iwhile j <= n:is_prime[j-1] = Falsej += itable = [ i for i in range(1, n+1) if is_prime[i-1]]return is_prime, tableN = int(input())_,t = sieve(2*N)s=set(t)ppow = []lent = len(t)i = 0while i<lent and t[i]**2<=2*N:ppow.append(t[i]**2)i+=1ans = 0for p in ppow:for j in range(lent):if p - t[j] in s and p - t[j]<=N and p <=N and t[j]<=N:ans+=1if t[j]>=p:breakprint(ans)