結果

問題 No.1632 Sorting Integers (GCD of M)
ユーザー nok0nok0
提出日時 2021-07-30 21:39:10
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 843 bytes
コンパイル時間 916 ms
コンパイル使用メモリ 86,688 KB
実行使用メモリ 71,452 KB
最終ジャッジ日時 2023-10-14 03:52:33
合計ジャッジ時間 8,086 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,296 KB
testcase_01 AC 74 ms
71,136 KB
testcase_02 AC 73 ms
71,204 KB
testcase_03 AC 73 ms
71,212 KB
testcase_04 AC 74 ms
70,904 KB
testcase_05 AC 73 ms
71,444 KB
testcase_06 WA -
testcase_07 AC 73 ms
71,240 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 73 ms
71,044 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 75 ms
71,200 KB
testcase_15 AC 74 ms
71,300 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 73 ms
71,356 KB
testcase_20 AC 74 ms
71,296 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 74 ms
71,100 KB
testcase_25 AC 75 ms
70,996 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 72 ms
71,168 KB
testcase_30 AC 75 ms
71,336 KB
testcase_31 AC 75 ms
71,272 KB
testcase_32 WA -
testcase_33 AC 74 ms
71,120 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 73 ms
71,360 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 73 ms
71,144 KB
testcase_43 WA -
testcase_44 AC 75 ms
71,032 KB
testcase_45 AC 73 ms
71,192 KB
testcase_46 WA -
testcase_47 AC 72 ms
71,276 KB
testcase_48 WA -
testcase_49 WA -
testcase_50 AC 74 ms
71,408 KB
testcase_51 AC 74 ms
71,196 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 AC 75 ms
71,252 KB
testcase_55 WA -
testcase_56 WA -
testcase_57 AC 73 ms
71,332 KB
testcase_58 WA -
testcase_59 AC 72 ms
71,088 KB
testcase_60 AC 72 ms
70,968 KB
testcase_61 AC 74 ms
71,244 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], mod)
        x += (i + 1) * one_mod(c[i], k)
        x %= k
    if x == 0:
        res = k
print(res % mod)
0