結果

問題 No.443 GCD of Permutation
ユーザー
提出日時 2016-11-12 19:24:53
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 432 bytes
コンパイル時間 434 ms
コンパイル使用メモリ 6,948 KB
実行使用メモリ 8,832 KB
最終ジャッジ日時 2024-11-25 21:27:46
合計ジャッジ時間 4,208 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 17 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import permutations
from fractions import gcd
import random

g = input()

digits = sorted(map(eval, str(g)))

if len(set(digits)) == 1:
  print g
elif 1 in digits or (any([x != 0 and x%2 == 0 for x in digits]) and any([x%3 == 0 for x in digits])):
  print 1
else:
  digit_len = len(str(g))
  S = []
  G = g
  sg = list(str(g))
  for _ in xrange(256):
    random.shuffle(sg)
    G = gcd(int("".join(sg)), G)
  print G
0