結果

問題 No.443 GCD of Permutation
ユーザー rlangevinrlangevin
提出日時 2023-10-26 00:15:36
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 364 bytes
コンパイル時間 490 ms
コンパイル使用メモリ 81,832 KB
実行使用メモリ 68,816 KB
最終ジャッジ日時 2023-10-26 00:15:40
合計ジャッジ時間 3,508 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,560 KB
testcase_01 AC 34 ms
53,496 KB
testcase_02 AC 33 ms
53,560 KB
testcase_03 AC 34 ms
53,560 KB
testcase_04 AC 35 ms
53,560 KB
testcase_05 AC 36 ms
53,496 KB
testcase_06 AC 35 ms
53,560 KB
testcase_07 AC 35 ms
53,560 KB
testcase_08 AC 35 ms
53,560 KB
testcase_09 AC 34 ms
53,560 KB
testcase_10 AC 34 ms
53,560 KB
testcase_11 AC 33 ms
53,560 KB
testcase_12 AC 35 ms
53,560 KB
testcase_13 AC 58 ms
53,560 KB
testcase_14 AC 34 ms
53,496 KB
testcase_15 AC 38 ms
59,720 KB
testcase_16 AC 39 ms
59,720 KB
testcase_17 AC 38 ms
59,720 KB
testcase_18 RE -
testcase_19 AC 38 ms
59,724 KB
testcase_20 RE -
testcase_21 AC 40 ms
59,724 KB
testcase_22 AC 36 ms
53,564 KB
testcase_23 AC 35 ms
53,564 KB
testcase_24 AC 35 ms
53,564 KB
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd

n = input()
if len(set(n)) == 1:
    print(n)
    exit()
    
D = [0] * 10
for i in n:
    D[int(i)] = 1
    
g = -1
for i in range(10):
    for j in range(i + 1, 10):
        if D[i] and D[j]:
            if g == -1:
                g = 9 * (j - i)
            else:
                g = gcd(g, 9 * (j - i))
            
print(gcd(int(n), g))
0