結果
問題 |
No.1632 Sorting Integers (GCD of M)
|
ユーザー |
![]() |
提出日時 | 2025-06-12 13:00:43 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,024 bytes |
コンパイル時間 | 348 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 54,256 KB |
最終ジャッジ日時 | 2025-06-12 13:06:57 |
合計ジャッジ時間 | 4,302 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 all_same = False digit = -1 for i in range(9): if c[i] == N: all_same = True digit = i + 1 break if all_same: # Compute (digit * (10^N - 1)/9) mod MOD mod9 = 9 * MOD pow10 = pow(10, N, mod9) numerator = (pow10 - 1) % mod9 # Ensure it's positive res = (digit * (numerator // 9)) % MOD print(res) else: # Compute sum of digits S = sum((i + 1) * count for i, count in enumerate(c)) # Determine sum contribution if S % 9 == 0: sum_contribution = 9 elif S % 3 == 0: sum_contribution = 3 else: sum_contribution = 1 # Check if all digits are even all_even = True for i in range(9): if c[i] > 0 and (i + 1) % 2 != 0: all_even = False break even_contribution = 2 if all_even else 1 gcd_val = sum_contribution * even_contribution print(gcd_val % MOD)