結果

問題 No.1632 Sorting Integers (GCD of M)
ユーザー lam6er
提出日時 2025-04-15 21:48:38
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 984 bytes
コンパイル時間 331 ms
コンパイル使用メモリ 82,292 KB
実行使用メモリ 54,516 KB
最終ジャッジ日時 2025-04-15 21:50:08
合計ジャッジ時間 4,109 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 43 WA * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10**9 + 7

N = int(input())
c = list(map(int, input().split()))

# Check if all digits are the same
count_non_zero = 0
digit = -1
for i in range(9):
    if c[i] > 0:
        count_non_zero += 1
        digit = i + 1

if count_non_zero == 1 and c[digit - 1] == N:
    d = digit
    inv9 = pow(9, MOD - 2, MOD)
    pow10 = pow(10, N, 9 * MOD)
    numerator = (pow10 - 1) % (9 * MOD)
    term = (numerator // 9) % MOD
    ans = (d * term) % MOD
    print(ans)
else:
    # Check if all digits are even
    a = 1
    for i in range(9):
        if (i + 1) % 2 != 0 and c[i] > 0:
            a = 0
            break
    
    # Check if all digits are 5
    b = 1
    for i in range(9):
        if (i + 1) != 5 and c[i] > 0:
            b = 0
            break
    
    sum_s = sum((i + 1) * c[i] for i in range(9))
    divisor = (2 ** a) * (5 ** b)
    S = sum_s // divisor
    
    from math import gcd
    g = gcd(S, 9)
    
    ans = ( (2 ** a) * (5 ** b) * g ) % MOD
    print(ans)
0