結果
問題 |
No.1632 Sorting Integers (GCD of M)
|
ユーザー |
![]() |
提出日時 | 2025-04-16 15:40:33 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,136 bytes |
コンパイル時間 | 164 ms |
コンパイル使用メモリ | 81,904 KB |
実行使用メモリ | 54,028 KB |
最終ジャッジ日時 | 2025-04-16 15:45:01 |
合計ジャッジ時間 | 3,815 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 43 WA * 16 |
ソースコード
MOD = 10**9 + 7 inv9 = 111111112 # Modular inverse of 9 modulo MOD def main(): import sys input = sys.stdin.read().split() N = int(input[0]) c = list(map(int, input[1:10])) # 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 # digits are 1-based if count_non_zero == 1 and c[digit-1] == N: # Compute the number as digit repeated N times mod MOD pow10 = pow(10, N, MOD) numerator = (pow10 - 1) % MOD res = digit * numerator % MOD res = res * inv9 % MOD print(res) return # Calculate sum_S sum_S = 0 for i in range(9): sum_S += (i + 1) * c[i] d = gcd(sum_S, 9) # 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 if all_even: d *= 2 print(d % MOD) def gcd(a, b): while b: a, b = b, a % b return a if __name__ == "__main__": main()