結果
問題 |
No.1632 Sorting Integers (GCD of M)
|
ユーザー |
![]() |
提出日時 | 2025-04-15 21:52:09 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 984 bytes |
コンパイル時間 | 160 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 54,512 KB |
最終ジャッジ日時 | 2025-04-15 21:53:44 |
合計ジャッジ時間 | 4,196 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 43 WA * 16 |
ソースコード
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)