結果
問題 | No.443 GCD of Permutation |
ユーザー | はむ吉🐹 |
提出日時 | 2017-01-03 21:39:52 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
RE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 434 bytes |
コンパイル時間 | 117 ms |
コンパイル使用メモリ | 10,752 KB |
実行使用メモリ | 9,976 KB |
最終ジャッジ日時 | 2023-10-11 03:39:09 |
合計ジャッジ時間 | 3,217 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 28 ms
9,596 KB |
testcase_01 | AC | 28 ms
9,828 KB |
testcase_02 | AC | 28 ms
9,696 KB |
testcase_03 | AC | 28 ms
9,828 KB |
testcase_04 | AC | 28 ms
9,680 KB |
testcase_05 | AC | 28 ms
9,792 KB |
testcase_06 | AC | 29 ms
9,852 KB |
testcase_07 | AC | 29 ms
9,788 KB |
testcase_08 | AC | 28 ms
9,684 KB |
testcase_09 | AC | 29 ms
9,696 KB |
testcase_10 | AC | 31 ms
9,596 KB |
testcase_11 | AC | 29 ms
9,696 KB |
testcase_12 | AC | 29 ms
9,864 KB |
testcase_13 | AC | 28 ms
9,780 KB |
testcase_14 | RE | - |
testcase_15 | AC | 29 ms
9,600 KB |
testcase_16 | AC | 28 ms
9,852 KB |
testcase_17 | AC | 29 ms
9,672 KB |
testcase_18 | RE | - |
testcase_19 | AC | 29 ms
9,852 KB |
testcase_20 | RE | - |
testcase_21 | AC | 29 ms
9,688 KB |
testcase_22 | AC | 29 ms
9,788 KB |
testcase_23 | AC | 29 ms
9,684 KB |
testcase_24 | AC | 29 ms
9,596 KB |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | RE | - |
testcase_29 | RE | - |
testcase_30 | RE | - |
testcase_31 | RE | - |
ソースコード
#!/usr/bin/env python3 import fractions import functools import itertools import math def gcd_of_permutations(n): if n < 10: return n ds = {int(d) for d in str(n)} xs = (9 * abs(a - b) for a, b in itertools.combinations(ds, 2)) g = functools.reduce(math.gcd, xs, 0) return math.gcd(g, n) if g != 0 else n def main(): print(gcd_of_permutations(int(input()))) if __name__ == '__main__': main()