結果

問題 No.1632 Sorting Integers (GCD of M)
ユーザー lam6er
提出日時 2025-04-15 21:52:07
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 603 bytes
コンパイル時間 271 ms
コンパイル使用メモリ 81,676 KB
実行使用メモリ 54,144 KB
最終ジャッジ日時 2025-04-15 21:53:36
合計ジャッジ時間 3,764 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 39 WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

MOD = 10**9 + 7

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

# Check if all digits are even (1,3,5,7,9 have counts zero)
all_even = True
for i in [0, 2, 4, 6, 8]:
    if c[i] > 0:
        all_even = False
        break

# Check if all digits are 5
all_five = (c[4] == N)

# Calculate the sum of all digits
sum_s = 0
for i in range(9):
    sum_s += (i + 1) * c[i]

# Compute GCD of sum_s and 9
g = math.gcd(sum_s, 9)

# Determine factors
factor_2 = 2 if all_even else 1
factor_5 = 5 if all_five else 1

# Calculate the result
result = (factor_2 * factor_5 * g) % MOD

print(result)
0