結果
| 問題 |
No.1632 Sorting Integers (GCD of M)
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-04-15 21:48:32 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,136 bytes |
| コンパイル時間 | 377 ms |
| コンパイル使用メモリ | 81,800 KB |
| 実行使用メモリ | 53,932 KB |
| 最終ジャッジ日時 | 2025-04-15 21:50:04 |
| 合計ジャッジ時間 | 3,896 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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()
lam6er