結果

問題 No.443 GCD of Permutation
コンテスト
ユーザー maspy
提出日時 2022-04-25 10:49:13
言語 Python3
(3.14.3 + numpy 2.4.2 + scipy 1.17.0)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 450 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 437 ms
コンパイル使用メモリ 20,960 KB
実行使用メモリ 20,808 KB
最終ジャッジ日時 2026-03-14 15:29:58
合計ジャッジ時間 5,933 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19 RE * 9
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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