結果

問題 No.443 GCD of Permutation
ユーザー maspymaspy
提出日時 2022-04-25 10:49:13
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 450 bytes
コンパイル時間 74 ms
コンパイル使用メモリ 10,908 KB
実行使用メモリ 9,660 KB
最終ジャッジ日時 2023-09-09 13:25:36
合計ジャッジ時間 1,898 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,716 KB
testcase_01 AC 19 ms
8,716 KB
testcase_02 AC 18 ms
8,724 KB
testcase_03 AC 20 ms
8,684 KB
testcase_04 AC 20 ms
8,676 KB
testcase_05 AC 20 ms
8,724 KB
testcase_06 AC 18 ms
8,868 KB
testcase_07 AC 20 ms
8,688 KB
testcase_08 AC 19 ms
8,792 KB
testcase_09 AC 19 ms
8,716 KB
testcase_10 AC 18 ms
8,856 KB
testcase_11 AC 19 ms
8,716 KB
testcase_12 AC 18 ms
8,892 KB
testcase_13 AC 19 ms
8,732 KB
testcase_14 AC 22 ms
9,308 KB
testcase_15 AC 19 ms
8,992 KB
testcase_16 AC 19 ms
8,960 KB
testcase_17 AC 19 ms
8,992 KB
testcase_18 RE -
testcase_19 AC 19 ms
8,804 KB
testcase_20 RE -
testcase_21 AC 20 ms
9,080 KB
testcase_22 AC 20 ms
8,792 KB
testcase_23 AC 19 ms
8,836 KB
testcase_24 AC 19 ms
8,804 KB
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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