結果
問題 |
No.1632 Sorting Integers (GCD of M)
|
ユーザー |
![]() |
提出日時 | 2025-06-12 18:11:04 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 883 bytes |
コンパイル時間 | 413 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 53,692 KB |
最終ジャッジ日時 | 2025-06-12 18:12:59 |
合計ジャッジ時間 | 4,276 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 43 WA * 16 |
ソースコード
import math MOD = 10**9 + 7 def main(): N = int(input().strip()) c = list(map(int, input().split())) # Check if all digits are the same non_zero = [i for i in range(9) if c[i] > 0] if len(non_zero) == 1: idx = non_zero[0] if c[idx] == N: d = idx + 1 pow_10 = pow(10, N, 9 * MOD) numerator = (pow_10 - 1) % (9 * MOD) term = (numerator // 9) % MOD ans = (d * term) % MOD print(ans) return # Case 2: Not all digits are the same all_even = True for i in range(9): if c[i] > 0 and (i + 1) % 2 != 0: all_even = False break S = sum((i + 1) * c[i] for i in range(9)) g = math.gcd(S, 9) factor = 2 if all_even else 1 ans = (factor * g) % MOD print(ans) if __name__ == "__main__": main()