結果
問題 | No.12 限定された素数 |
ユーザー |
👑 |
提出日時 | 2022-07-04 17:54:05 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 479 ms / 5,000 ms |
コード長 | 943 bytes |
コンパイル時間 | 871 ms |
コンパイル使用メモリ | 82,168 KB |
実行使用メモリ | 140,848 KB |
最終ジャッジ日時 | 2024-12-14 09:19:23 |
合計ジャッジ時間 | 12,864 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 26 |
ソースコード
from cmath import eN = 5000100isprime = [True] * Nisprime[0] = isprime[1] = Falsefor i in range(2, int(N ** 0.5 + 1)):if not isprime[i]:continuefor j in range(i * i, N, i):isprime[j] = Falselst = [i for i in range(N) if isprime[i]]while lst[-1] >= 5000000:lst.pop()n = int(input())A = list(map(int, input().split()))tf = [False] * 10for a in A:tf[a] = Truebef = 0ans = -1used = [False] * 10tot = 0for a in lst:ok = Truese = set()for b in str(a):b = int(b)if tf[b]:se.add(b)else:ok = Falsebreakif ok:for b in se:if not used[b]:used[b] = Truetot += 1else:if tot == n:ans = max(ans, a - bef - 2)used = [False] * 10tot = 0bef = aif tot == n:ans = max(ans, 5000001 - bef - 2)print(ans)