結果

問題 No.443 GCD of Permutation
ユーザー maspymaspy
提出日時 2023-06-30 14:05:06
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 24 ms / 1,000 ms
コード長 484 bytes
コンパイル時間 73 ms
コンパイル使用メモリ 11,004 KB
実行使用メモリ 9,692 KB
最終ジャッジ日時 2023-09-21 07:38:58
合計ジャッジ時間 3,081 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
8,792 KB
testcase_01 AC 19 ms
8,568 KB
testcase_02 AC 19 ms
8,824 KB
testcase_03 AC 20 ms
8,848 KB
testcase_04 AC 21 ms
8,656 KB
testcase_05 AC 20 ms
8,656 KB
testcase_06 AC 22 ms
8,832 KB
testcase_07 AC 20 ms
8,792 KB
testcase_08 AC 20 ms
8,652 KB
testcase_09 AC 20 ms
8,804 KB
testcase_10 AC 20 ms
8,808 KB
testcase_11 AC 21 ms
8,724 KB
testcase_12 AC 20 ms
8,736 KB
testcase_13 AC 20 ms
8,764 KB
testcase_14 AC 23 ms
9,400 KB
testcase_15 AC 22 ms
9,052 KB
testcase_16 AC 20 ms
8,928 KB
testcase_17 AC 21 ms
8,948 KB
testcase_18 AC 23 ms
9,456 KB
testcase_19 AC 21 ms
8,968 KB
testcase_20 AC 23 ms
9,500 KB
testcase_21 AC 21 ms
8,952 KB
testcase_22 AC 20 ms
8,764 KB
testcase_23 AC 19 ms
8,716 KB
testcase_24 AC 20 ms
8,828 KB
testcase_25 AC 24 ms
9,664 KB
testcase_26 AC 23 ms
9,460 KB
testcase_27 AC 22 ms
9,004 KB
testcase_28 AC 24 ms
9,692 KB
testcase_29 AC 23 ms
9,624 KB
testcase_30 AC 24 ms
9,640 KB
testcase_31 AC 24 ms
9,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.set_int_max_str_digits(10**6)

from functools import reduce
from math import gcd

Nstr = [int(x) - ord('0') for x in read().rstrip()]

nums = sorted(set(Nstr))

if len(nums) == 1:
    print(''.join(map(str,Nstr)))
    exit()

diff = [y - x for x,y in zip(nums,nums[1:])]

d = reduce(gcd,diff)

d *= 9
N = int(''.join(map(str,Nstr)))
answer = gcd(N,d)
print(answer)
0