結果

問題 No.443 GCD of Permutation
ユーザー H3PO4
提出日時 2021-07-11 08:41:57
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 268 bytes
コンパイル時間 96 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-07-02 02:58:41
合計ジャッジ時間 2,127 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19 RE * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools
from math import gcd


def solve(N):
    Nt = tuple(int(x) for x in N)
    st = set(Nt)

    if len(st) == 1:
        return N

    g = gcd(*[9 * abs(x - y) for x, y in itertools.combinations(st, 2)])
    return gcd(int(N), g)


print(solve(input()))
0