結果

問題 No.443 GCD of Permutation
ユーザー ​
提出日時 2016-11-12 19:24:53
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 432 bytes
コンパイル時間 912 ms
コンパイル使用メモリ 6,740 KB
実行使用メモリ 10,756 KB
最終ジャッジ日時 2023-08-17 03:48:57
合計ジャッジ時間 5,450 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
10,380 KB
testcase_01 AC 26 ms
10,384 KB
testcase_02 AC 26 ms
10,472 KB
testcase_03 AC 26 ms
10,380 KB
testcase_04 AC 27 ms
10,252 KB
testcase_05 AC 26 ms
10,252 KB
testcase_06 AC 26 ms
10,384 KB
testcase_07 WA -
testcase_08 AC 26 ms
10,496 KB
testcase_09 WA -
testcase_10 AC 25 ms
10,256 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 25 ms
10,256 KB
testcase_14 AC 65 ms
10,696 KB
testcase_15 WA -
testcase_16 AC 30 ms
10,528 KB
testcase_17 AC 172 ms
10,308 KB
testcase_18 AC 60 ms
10,596 KB
testcase_19 AC 33 ms
10,280 KB
testcase_20 AC 58 ms
10,420 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 27 ms
10,380 KB
testcase_24 WA -
testcase_25 AC 60 ms
10,492 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 63 ms
10,440 KB
testcase_29 AC 951 ms
10,756 KB
testcase_30 AC 963 ms
10,536 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 _ in xrange(256):
    random.shuffle(sg)
    G = gcd(int("".join(sg)), G)
  print G
0