結果
問題 | No.12 限定された素数 |
ユーザー |
![]() |
提出日時 | 2024-11-07 17:00:53 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 884 bytes |
コンパイル時間 | 269 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 298,140 KB |
最終ジャッジ日時 | 2024-11-07 17:01:46 |
合計ジャッジ時間 | 48,324 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | TLE * 8 -- * 18 |
ソースコード
def seachPrimeNum(N): if N < 2: return [] max = int(N ** 0.5) seachList = [i for i in range(2, N + 1)] primeNum = [] while seachList[0] <= max: primeNum.append(seachList[0]) tmp = seachList[0] seachList = [i for i in seachList if i % tmp != 0] primeNum.extend(seachList) return primeNum def conv(x): ret = 0 while x: ret |= (1 << x % 10) x //= 10 return ret PL = seachPrimeNum(5 * 10 ** 6) NP = len(PL) PL.append(5 * 10 ** 6 + 1) l = 1 N = int(input()) A = list(map(int,input().split())) B = 0 for a in A: B |= (1<<a) NB = ((1<<10)-1) ^ B ans = 0 tmp = 0 for i in range(NP): p = PL[i] if conv(p) & NB: l = p + 1 tmp = 0 else: tmp |= conv(p) if tmp == B: ans = max(ans,PL[i + 1] - 1 - l) if ans == 0: print(-1) else: print(ans)