結果

問題 No.1632 Sorting Integers (GCD of M)
ユーザー gew1fw
提出日時 2025-06-12 20:47:19
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 723 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 81,584 KB
実行使用メモリ 53,668 KB
最終ジャッジ日時 2025-06-12 20:48:28
合計ジャッジ時間 3,883 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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 even
all_even = True
for i in range(9):
    digit = i + 1
    if c[i] > 0 and digit % 2 != 0:
        all_even = False
        break

# Check if all digits are 5
all_5 = True
for i in range(9):
    digit = i + 1
    if c[i] > 0 and digit != 5:
        all_5 = False
        break

# Compute the sum of all digits
s = sum((i + 1) * c[i] for i in range(9))

# Compute the maximum exponent e where 3^e divides s
e = 0
temp = s
while temp % 3 == 0:
    e += 1
    temp = temp // 3

# Compute the divisor d
d = 1
if all_even:
    d *= 2
if all_5:
    d *= 5
d *= pow(3, e, MOD)
d %= MOD  # Ensure the result is within MOD

print(d)
0