結果

問題 No.443 GCD of Permutation
ユーザー mbanmban
提出日時 2017-07-26 07:32:52
言語 PyPy3
(7.3.15)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 677 bytes
コンパイル時間 201 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 67,328 KB
最終ジャッジ日時 2024-04-22 01:31:21
合計ジャッジ時間 3,222 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
52,096 KB
testcase_01 AC 46 ms
52,352 KB
testcase_02 AC 47 ms
51,968 KB
testcase_03 AC 42 ms
51,968 KB
testcase_04 AC 42 ms
51,840 KB
testcase_05 AC 44 ms
52,480 KB
testcase_06 AC 42 ms
52,608 KB
testcase_07 AC 42 ms
52,480 KB
testcase_08 AC 41 ms
51,968 KB
testcase_09 AC 44 ms
51,840 KB
testcase_10 AC 41 ms
52,224 KB
testcase_11 AC 42 ms
52,096 KB
testcase_12 AC 41 ms
51,840 KB
testcase_13 AC 41 ms
52,608 KB
testcase_14 AC 45 ms
58,240 KB
testcase_15 AC 44 ms
58,572 KB
testcase_16 AC 43 ms
58,240 KB
testcase_17 AC 43 ms
58,368 KB
testcase_18 RE -
testcase_19 AC 44 ms
58,368 KB
testcase_20 RE -
testcase_21 AC 46 ms
58,496 KB
testcase_22 AC 41 ms
52,480 KB
testcase_23 AC 40 ms
51,968 KB
testcase_24 AC 40 ms
52,224 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