結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,336 KB
testcase_01 AC 76 ms
71,648 KB
testcase_02 AC 76 ms
71,724 KB
testcase_03 AC 74 ms
71,252 KB
testcase_04 AC 73 ms
71,692 KB
testcase_05 AC 77 ms
71,672 KB
testcase_06 AC 75 ms
71,720 KB
testcase_07 AC 75 ms
71,336 KB
testcase_08 AC 74 ms
71,568 KB
testcase_09 AC 74 ms
71,756 KB
testcase_10 AC 74 ms
71,536 KB
testcase_11 AC 75 ms
71,636 KB
testcase_12 AC 75 ms
71,340 KB
testcase_13 AC 75 ms
71,404 KB
testcase_14 AC 76 ms
71,292 KB
testcase_15 AC 75 ms
71,460 KB
testcase_16 AC 74 ms
71,464 KB
testcase_17 AC 75 ms
71,460 KB
testcase_18 AC 74 ms
71,464 KB
testcase_19 WA -
testcase_20 AC 75 ms
71,716 KB
testcase_21 WA -
testcase_22 AC 76 ms
71,680 KB
testcase_23 AC 76 ms
71,756 KB
testcase_24 AC 77 ms
71,404 KB
testcase_25 AC 77 ms
71,696 KB
testcase_26 WA -
testcase_27 AC 76 ms
71,588 KB
testcase_28 AC 77 ms
71,628 KB
testcase_29 AC 77 ms
71,804 KB
testcase_30 AC 77 ms
71,388 KB
testcase_31 AC 76 ms
71,588 KB
testcase_32 AC 77 ms
71,256 KB
testcase_33 AC 77 ms
71,388 KB
testcase_34 WA -
testcase_35 AC 77 ms
71,760 KB
testcase_36 AC 77 ms
71,536 KB
testcase_37 WA -
testcase_38 AC 77 ms
71,724 KB
testcase_39 AC 75 ms
71,408 KB
testcase_40 AC 75 ms
71,540 KB
testcase_41 AC 75 ms
71,380 KB
testcase_42 AC 77 ms
71,732 KB
testcase_43 WA -
testcase_44 AC 78 ms
71,704 KB
testcase_45 AC 77 ms
71,344 KB
testcase_46 WA -
testcase_47 AC 76 ms
71,720 KB
testcase_48 AC 77 ms
71,388 KB
testcase_49 AC 76 ms
71,396 KB
testcase_50 AC 76 ms
71,608 KB
testcase_51 AC 80 ms
71,352 KB
testcase_52 AC 75 ms
71,684 KB
testcase_53 AC 75 ms
71,772 KB
testcase_54 AC 75 ms
71,532 KB
testcase_55 AC 75 ms
71,544 KB
testcase_56 AC 75 ms
71,720 KB
testcase_57 AC 75 ms
71,604 KB
testcase_58 AC 75 ms
71,544 KB
testcase_59 AC 76 ms
71,536 KB
testcase_60 AC 76 ms
71,636 KB
testcase_61 AC 76 ms
71,384 KB
testcase_62 AC 75 ms
71,456 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
    print(ans)
    assert N == sum(C)
    

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