結果
問題 |
No.1632 Sorting Integers (GCD of M)
|
ユーザー |
![]() |
提出日時 | 2025-03-20 21:06:39 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 763 bytes |
コンパイル時間 | 223 ms |
コンパイル使用メモリ | 82,648 KB |
実行使用メモリ | 54,376 KB |
最終ジャッジ日時 | 2025-03-20 21:06:44 |
合計ジャッジ時間 | 3,734 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 43 WA * 16 |
ソースコード
import math MOD = 10**9 + 7 n = int(input()) c = list(map(int, input().split())) count_nonzero = 0 digit = -1 for i in range(9): if c[i] > 0: count_nonzero += 1 digit = i + 1 if count_nonzero == 1: d = digit K = 9 * MOD pow10n = pow(10, n, K) pow10n_minus_1 = (pow10n - 1) % K s = pow10n_minus_1 // 9 res = (d * s) % MOD print(res) else: factors = 1 all_even = True for idx in [0, 2, 4, 6, 8]: if c[idx] != 0: all_even = False break if all_even: factors *= 2 if c[4] == n: factors *= 5 sum_S = 0 for i in range(9): sum_S += (i + 1) * c[i] g = math.gcd(sum_S, 9) factors *= g print(factors % MOD)