結果

問題 No.1632 Sorting Integers (GCD of M)
ユーザー nok0nok0
提出日時 2021-07-30 21:41:18
言語 PyPy3
(7.3.15)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 841 bytes
コンパイル時間 894 ms
コンパイル使用メモリ 81,832 KB
実行使用メモリ 53,748 KB
最終ジャッジ日時 2023-10-21 16:15:25
合計ジャッジ時間 3,709 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,744 KB
testcase_01 AC 36 ms
53,744 KB
testcase_02 AC 34 ms
53,680 KB
testcase_03 AC 34 ms
53,744 KB
testcase_04 AC 33 ms
53,744 KB
testcase_05 AC 33 ms
53,748 KB
testcase_06 AC 33 ms
53,744 KB
testcase_07 AC 32 ms
53,744 KB
testcase_08 AC 33 ms
53,744 KB
testcase_09 AC 32 ms
53,744 KB
testcase_10 AC 32 ms
53,744 KB
testcase_11 AC 32 ms
53,744 KB
testcase_12 AC 37 ms
53,744 KB
testcase_13 AC 33 ms
53,748 KB
testcase_14 AC 32 ms
53,744 KB
testcase_15 AC 33 ms
53,744 KB
testcase_16 AC 32 ms
53,744 KB
testcase_17 AC 31 ms
53,744 KB
testcase_18 AC 36 ms
53,748 KB
testcase_19 AC 32 ms
53,744 KB
testcase_20 AC 35 ms
53,744 KB
testcase_21 AC 36 ms
53,744 KB
testcase_22 AC 34 ms
53,744 KB
testcase_23 AC 35 ms
53,744 KB
testcase_24 AC 33 ms
53,744 KB
testcase_25 AC 33 ms
53,744 KB
testcase_26 AC 34 ms
53,744 KB
testcase_27 AC 34 ms
53,744 KB
testcase_28 AC 34 ms
53,744 KB
testcase_29 AC 35 ms
53,748 KB
testcase_30 AC 34 ms
53,744 KB
testcase_31 AC 34 ms
53,748 KB
testcase_32 AC 33 ms
53,744 KB
testcase_33 AC 32 ms
53,744 KB
testcase_34 AC 32 ms
53,744 KB
testcase_35 AC 31 ms
53,744 KB
testcase_36 AC 32 ms
53,744 KB
testcase_37 AC 32 ms
53,744 KB
testcase_38 AC 32 ms
53,744 KB
testcase_39 AC 35 ms
53,744 KB
testcase_40 AC 34 ms
53,744 KB
testcase_41 AC 35 ms
53,744 KB
testcase_42 AC 32 ms
53,744 KB
testcase_43 AC 32 ms
53,744 KB
testcase_44 AC 35 ms
53,744 KB
testcase_45 AC 34 ms
53,744 KB
testcase_46 AC 35 ms
53,744 KB
testcase_47 AC 34 ms
53,744 KB
testcase_48 AC 33 ms
53,744 KB
testcase_49 AC 33 ms
53,744 KB
testcase_50 AC 36 ms
53,744 KB
testcase_51 AC 34 ms
53,744 KB
testcase_52 AC 34 ms
53,744 KB
testcase_53 AC 34 ms
53,744 KB
testcase_54 AC 33 ms
53,744 KB
testcase_55 AC 34 ms
53,744 KB
testcase_56 AC 35 ms
53,744 KB
testcase_57 AC 35 ms
53,744 KB
testcase_58 AC 33 ms
53,744 KB
testcase_59 AC 33 ms
53,684 KB
testcase_60 AC 33 ms
53,680 KB
testcase_61 AC 33 ms
53,680 KB
testcase_62 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd

mod = 10 ** 9 + 7

n = int(input())
c = list(map(int, input().split()))
g = 0
for i in range(9):
    for j in range(i + 1, 9):
        if c[i] and c[j]:
            g = gcd(g, 9 * (j - i))


def one_mod(n, mod):
    if n == 0:
        return 0
    if n == 1:
        return 1
    if n % 2 == 0:
        return one_mod(n // 2, mod) * (1 + pow(10, n // 2, mod))
    return one_mod(n - 1, mod) + pow(10, n - 1, mod)


res = 0
if g == 0:
    x = 0
    for i in range(9):
        v = pow(10, c[i], mod)
        x *= v
        x %= mod
        x += (i + 1) * one_mod(c[i], mod)
    print(x)
    exit()
for k in range(1, g + 1):
    if g % k:
        continue
    x = 0
    for i in range(9):
        x *= pow(10, c[i], k)
        x += (i + 1) * one_mod(c[i], k)
        x %= k
    if x == 0:
        res = k
print(res % mod)
0