結果

問題 No.1632 Sorting Integers (GCD of M)
ユーザー LyricalMaestroLyricalMaestro
提出日時 2024-01-28 03:10:43
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,671 bytes
コンパイル時間 342 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 53,460 KB
最終ジャッジ日時 2024-01-28 03:10:49
合計ジャッジ時間 5,102 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

## https://yukicoder.me/problems/no/1632

MOD = 10 ** 9 + 7

def dividable_by2(C):
    for i in range(9):
        if (i + 1) % 2 != 0 and C[i] > 0:
            return False
    return True    

def dividable_by4(C):
    for i in range(9):
        if (i + 1) % 4 != 0 and C[i] > 0:
            return False
    return True


def main():
    N = int(input())
    C = list(map(int, input().split()))

    posisive_num = 0
    for c in C:
        if c > 0:
            posisive_num += 1
    if posisive_num == 1:
        # 1つだけの正の数字がある場合
        d = 0
        for i in range(9):
            if C[i] > 0:
                d = i + 1
                break
        
        answer = 0
        d_num = 1
        base = d
        while N > 0:
            y = pow(10, d_num, MOD)
            if N % 2 == 1:
                answer *= y
                answer %= MOD
                answer += base
                answer %= MOD
            
            base0 = (base * y) % MOD
            base0 %= MOD
            base = (base0 + base) % MOD
            d_num *= 2
            N //= 2
        print(answer)

    else:
        # 2つ以上の正の数字がある場合
        # 1. 2で割れるか?
        gcd = 1
        if dividable_by2(C):
            if dividable_by4(C):
                gcd = 4
            else:
                gcd = 2
        
        # 2. 3で割れるか?
        a = 0
        for i in range(9):
            a += (i + 1) * C[i]
        if a % 3 == 0:
            if a % 9 == 0:
                gcd *= 9
            else:
                gcd *= 3
        print(gcd)

        


        




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