結果

問題 No.1632 Sorting Integers (GCD of M)
ユーザー tamatotamato
提出日時 2021-07-31 10:57:32
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,441 bytes
コンパイル時間 294 ms
コンパイル使用メモリ 87,392 KB
実行使用メモリ 71,856 KB
最終ジャッジ日時 2023-10-14 14:37:34
合計ジャッジ時間 7,142 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
71,556 KB
testcase_01 AC 77 ms
71,332 KB
testcase_02 AC 77 ms
71,404 KB
testcase_03 AC 80 ms
71,580 KB
testcase_04 AC 75 ms
71,652 KB
testcase_05 AC 73 ms
71,648 KB
testcase_06 AC 75 ms
71,660 KB
testcase_07 AC 77 ms
71,668 KB
testcase_08 AC 77 ms
71,656 KB
testcase_09 AC 74 ms
71,540 KB
testcase_10 AC 76 ms
71,480 KB
testcase_11 AC 77 ms
71,760 KB
testcase_12 AC 81 ms
71,736 KB
testcase_13 AC 76 ms
71,760 KB
testcase_14 AC 77 ms
71,676 KB
testcase_15 AC 73 ms
71,484 KB
testcase_16 AC 74 ms
71,456 KB
testcase_17 AC 75 ms
71,584 KB
testcase_18 AC 74 ms
71,276 KB
testcase_19 AC 74 ms
71,484 KB
testcase_20 AC 76 ms
71,464 KB
testcase_21 WA -
testcase_22 AC 75 ms
71,328 KB
testcase_23 AC 74 ms
71,424 KB
testcase_24 AC 74 ms
71,576 KB
testcase_25 AC 73 ms
71,560 KB
testcase_26 WA -
testcase_27 AC 75 ms
71,584 KB
testcase_28 AC 74 ms
71,276 KB
testcase_29 AC 76 ms
71,480 KB
testcase_30 AC 76 ms
71,656 KB
testcase_31 AC 78 ms
71,628 KB
testcase_32 AC 75 ms
71,828 KB
testcase_33 AC 75 ms
71,716 KB
testcase_34 WA -
testcase_35 AC 73 ms
71,576 KB
testcase_36 AC 74 ms
71,484 KB
testcase_37 WA -
testcase_38 AC 75 ms
71,560 KB
testcase_39 AC 74 ms
71,576 KB
testcase_40 AC 74 ms
71,632 KB
testcase_41 AC 73 ms
71,736 KB
testcase_42 AC 74 ms
71,556 KB
testcase_43 WA -
testcase_44 AC 73 ms
71,684 KB
testcase_45 AC 74 ms
71,624 KB
testcase_46 WA -
testcase_47 AC 75 ms
71,332 KB
testcase_48 AC 74 ms
71,428 KB
testcase_49 AC 73 ms
71,708 KB
testcase_50 AC 79 ms
71,484 KB
testcase_51 AC 75 ms
71,272 KB
testcase_52 AC 74 ms
71,452 KB
testcase_53 AC 76 ms
71,368 KB
testcase_54 AC 75 ms
71,604 KB
testcase_55 AC 74 ms
71,660 KB
testcase_56 AC 73 ms
71,372 KB
testcase_57 AC 73 ms
71,656 KB
testcase_58 AC 73 ms
71,748 KB
testcase_59 AC 73 ms
71,604 KB
testcase_60 AC 75 ms
71,584 KB
testcase_61 AC 74 ms
71,452 KB
testcase_62 AC 79 ms
71,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    C = [0] + list(map(int, input().split()))

    nz = [0] * 10
    for i in range(1, 10):
        if C[i]:
            nz[i] = 1
    if sum(nz) == 1:
        c = 0
        for i in range(1, 10):
            if nz[i]:
                c = i
                break
        print((c * (pow(10, N, mod) - 1) * pow(9, mod-2, mod))%mod)
        exit()

    ans = 1
    # 2
    flg2 = 1
    for i in range(1, 10):
        if i % 2 and C[i]:
            flg2 = 0
            break
    if flg2:
        ans = 2

    # 4
    flg4 = 1
    for i in range(1, 10):
        if i % 4 and C[i]:
            flg4 = 0
            break
    if flg4:
        ans = 4

    # 3, 9
    S = 0
    for i, c in enumerate(C):
        S = S + c * i
    if S % 9 == 0:
        ans *= 9
    elif S % 3 == 0:
        ans *= 3

    # 7
    T = set()
    for i in range(1, 10):
        if C[i]:
            T.add(i)
    T = sorted(list(T))
    if T == [1, 8] or T == [2, 9]:
        if N % 6 == 0:
            ans *= 7
    
    # 27
    U = set()
    for i in range(1, 10):
        if C[i]:
            U.add(i)
    U = sorted(list(U))
    flg27 = 1
    for u1 in U:
        for u2 in U:
            if (u1 - u2) % 3:
                flg27 = 0
    if flg27:
        if N % 27 == 0:
            ans *= 3
    
    print(ans)


if __name__ == '__main__':
    main()
0