結果
| 問題 | No.443 GCD of Permutation |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-11-11 23:31:56 |
| 言語 | Python2 (2.7.18) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 395 bytes |
| コンパイル時間 | 637 ms |
| コンパイル使用メモリ | 7,076 KB |
| 実行使用メモリ | 18,724 KB |
| 最終ジャッジ日時 | 2024-11-25 09:36:16 |
| 合計ジャッジ時間 | 27,812 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 15 TLE * 13 |
ソースコード
from itertools import permutations
from fractions import gcd
g = input()
digits = map(eval, set(str(g)))
if len(digits) == 1:
print g
else:
digit_len = len(str(g))
digits = map(eval, str(g))
S = []
G = g
for p in permutations(digits, r=digit_len):
d = int("".join(map(str, p)))
if d in S:
continue
S += [d]
G = gcd(G, d)
if G == 1:
break
print G