結果
| 問題 |
No.1632 Sorting Integers (GCD of M)
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 12:55:02 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 883 bytes |
| コンパイル時間 | 276 ms |
| コンパイル使用メモリ | 82,884 KB |
| 実行使用メモリ | 54,396 KB |
| 最終ジャッジ日時 | 2025-06-12 12:59:46 |
| 合計ジャッジ時間 | 4,558 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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()
gew1fw