結果

問題 No.443 GCD of Permutation
ユーザー ​
提出日時 2016-11-12 03:56:36
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 494 bytes
コンパイル時間 827 ms
コンパイル使用メモリ 6,632 KB
実行使用メモリ 10,776 KB
最終ジャッジ日時 2023-08-17 01:49:45
合計ジャッジ時間 4,421 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
10,520 KB
testcase_01 AC 25 ms
10,248 KB
testcase_02 AC 25 ms
10,288 KB
testcase_03 AC 25 ms
10,488 KB
testcase_04 AC 25 ms
10,264 KB
testcase_05 AC 24 ms
10,372 KB
testcase_06 AC 25 ms
10,264 KB
testcase_07 WA -
testcase_08 AC 26 ms
10,456 KB
testcase_09 WA -
testcase_10 AC 25 ms
10,312 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 25 ms
10,248 KB
testcase_14 AC 64 ms
10,616 KB
testcase_15 WA -
testcase_16 AC 30 ms
10,572 KB
testcase_17 AC 88 ms
10,448 KB
testcase_18 AC 60 ms
10,456 KB
testcase_19 AC 32 ms
10,524 KB
testcase_20 AC 57 ms
10,476 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 25 ms
10,464 KB
testcase_24 WA -
testcase_25 AC 59 ms
10,668 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 63 ms
10,660 KB
testcase_29 AC 424 ms
10,776 KB
testcase_30 AC 428 ms
10,644 KB
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

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 x in xrange(100):
    if G != 1:
      random.shuffle(sg)
      d = int("".join(sg))
      G = gcd(G, d)
      if G == 1:
        break
  print G
0