結果

問題 No.443 GCD of Permutation
ユーザー ​
提出日時 2016-11-11 23:31:56
言語 Python2
(2.7.18)
結果
TLE  
実行時間 -
コード長 395 bytes
コンパイル時間 1,051 ms
コンパイル使用メモリ 7,004 KB
実行使用メモリ 7,812 KB
最終ジャッジ日時 2023-08-16 19:45:18
合計ジャッジ時間 5,193 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
7,804 KB
testcase_01 AC 22 ms
7,812 KB
testcase_02 AC 22 ms
7,780 KB
testcase_03 AC 24 ms
7,772 KB
testcase_04 AC 22 ms
7,664 KB
testcase_05 AC 23 ms
7,728 KB
testcase_06 AC 23 ms
7,660 KB
testcase_07 AC 28 ms
7,720 KB
testcase_08 AC 22 ms
7,616 KB
testcase_09 AC 24 ms
7,672 KB
testcase_10 AC 23 ms
7,784 KB
testcase_11 AC 23 ms
7,620 KB
testcase_12 AC 22 ms
7,616 KB
testcase_13 AC 22 ms
7,628 KB
testcase_14 AC 27 ms
7,664 KB
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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
0