結果
問題 | No.774 tatyamと素数大富豪 |
ユーザー |
|
提出日時 | 2018-12-22 02:01:12 |
言語 | PyPy2 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 788 bytes |
コンパイル時間 | 1,100 ms |
コンパイル使用メモリ | 76,444 KB |
実行使用メモリ | 102,996 KB |
最終ジャッジ日時 | 2024-09-25 09:56:09 |
合計ジャッジ時間 | 10,564 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 WA * 2 |
other | TLE * 2 -- * 12 |
ソースコード
from random import randintfrom itertools import permutationsdef miller_rabin(n, k = 40):if (n & 1) == 0:return Falseif sum(map(int, list(str(n)))) % 3 == 0:return Falsed = n - 1s = 0while (d & 1) == 0:s += 1d >>= 1for _ in xrange(k):a = randint(1, n - 1)if pow(a, d, n) == 1:continuecomposite = Truefor r in xrange(s):if pow(a, 2 * r * d, n) == n - 1:composite = Falsebreakif composite:return Truereturn TrueN = input()A = sorted(map(int, raw_input().split()))ans = -1for p in permutations(A):n = int(''.join(map(str, p)))if miller_rabin(n):ans = max(ans, n)print ans