結果

問題 No.443 GCD of Permutation
ユーザー mbanmban
提出日時 2017-07-26 07:32:02
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 673 bytes
コンパイル時間 141 ms
コンパイル使用メモリ 82,200 KB
実行使用メモリ 69,392 KB
最終ジャッジ日時 2024-04-17 23:46:07
合計ジャッジ時間 2,406 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
51,840 KB
testcase_01 RE -
testcase_02 AC 35 ms
51,712 KB
testcase_03 AC 35 ms
51,712 KB
testcase_04 AC 34 ms
51,840 KB
testcase_05 RE -
testcase_06 AC 35 ms
51,840 KB
testcase_07 AC 35 ms
51,968 KB
testcase_08 AC 35 ms
52,096 KB
testcase_09 AC 35 ms
51,712 KB
testcase_10 AC 35 ms
52,224 KB
testcase_11 AC 36 ms
51,840 KB
testcase_12 AC 40 ms
51,712 KB
testcase_13 AC 37 ms
51,968 KB
testcase_14 RE -
testcase_15 AC 40 ms
58,368 KB
testcase_16 AC 41 ms
58,240 KB
testcase_17 AC 40 ms
58,624 KB
testcase_18 RE -
testcase_19 AC 41 ms
57,856 KB
testcase_20 RE -
testcase_21 AC 40 ms
58,624 KB
testcase_22 AC 37 ms
51,840 KB
testcase_23 AC 36 ms
51,712 KB
testcase_24 AC 36 ms
51,968 KB
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

def GCD(a, b):
    if a < b:
        t = a
        a = b
        b = t
    if b == 0:
        return a
    r = a % b
    while r > 0:
        a = b
        b = r
        r = a % b
    return b


N = input()

Use = [False for i in range(10)]

for c in N:
    Use[int(c)] = True

if Use.count(True) == 1:
    print(N)
else:
    g = 0

    for i in range(9):
        if not Use[i]:
            continue
        for j in range(i + 1, 10):
            if not Use[j]:
                continue
            g = GCD(g, 9 * (j - i))

    IntegerN = int(N)

    anser = 1

    for i in range(1, g + 1):
        if g % i == 0 and IntegerN % i == 0:
            anser = i

print(anser)
0