結果
問題 |
No.1632 Sorting Integers (GCD of M)
|
ユーザー |
![]() |
提出日時 | 2025-06-12 18:15:16 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 842 bytes |
コンパイル時間 | 210 ms |
コンパイル使用メモリ | 82,468 KB |
実行使用メモリ | 54,420 KB |
最終ジャッジ日時 | 2025-06-12 18:15:59 |
合計ジャッジ時間 | 3,849 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 43 WA * 16 |
ソースコード
MOD = 10**9 + 7 N = int(input()) c = list(map(int, input().split())) count_non_zero = sum(1 for x in c if x > 0) if count_non_zero == 1: # Find the digit d = 0 for i in range(9): if c[i] > 0: d = i + 1 break # Compute (d * (10^N - 1) / 9) mod MOD mod_part = 9 * MOD pow10 = pow(10, N, mod_part) numerator = (pow10 - 1) % mod_part term = numerator // 9 res = (d * term) % MOD print(res) else: S = sum((i + 1) * c[i] for i in range(9)) if S % 9 == 0: d_sum = 9 elif S % 3 == 0: d_sum = 3 else: d_sum = 1 all_even = True for i in range(9): if c[i] > 0 and (i + 1) % 2 != 0: all_even = False break factor_2 = 2 if all_even else 1 gcd = d_sum * factor_2 print(gcd % MOD)