結果

問題 No.443 GCD of Permutation
ユーザー はむ吉🐹
提出日時 2016-11-14 22:51:05
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 356 bytes
コンパイル時間 76 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 11,392 KB
最終ジャッジ日時 2024-11-26 01:20:27
合計ジャッジ時間 2,194 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 4
other RE * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3

import fractions
import functools
import itertools


def gcd_of_permutations(n):
    ds = (int(d) for d in str(n))
    xs = (9 * abs(a - b) for a, b in itertools.combinations(ds, 2))
    return functools.reduce(fractions.gcd, xs, n)


def main():
    print(gcd_of_permutations(int(input())))


if __name__ == '__main__':
    main()
0