結果
| 問題 |
No.1632 Sorting Integers (GCD of M)
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-31 17:23:34 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,318 bytes |
| コンパイル時間 | 315 ms |
| コンパイル使用メモリ | 82,300 KB |
| 実行使用メモリ | 54,260 KB |
| 最終ジャッジ日時 | 2025-03-31 17:23:55 |
| 合計ジャッジ時間 | 4,058 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 43 WA * 16 |
ソースコード
MOD = 10**9 + 7
def main():
import sys
input = sys.stdin.read().split()
N = int(input[0])
c = list(map(int, input[1:10]))
# Check if there's exactly one digit type and its count is N
count_non_zero = 0
single_i = -1
for i in range(9):
if c[i] > 0:
count_non_zero += 1
single_i = i + 1 # digits are 1-based
if count_non_zero == 1 and c[single_i-1] == N:
# Compute the number with N digits of single_i
# number = single_i * (10^N -1)/9 mod MOD
i = single_i
mod = MOD * 9
pow10n = pow(10, N, mod)
m = (pow10n - 1) % mod
inv9 = 111111112 # pow(9, MOD-2, MOD)
term = (m // 9) * i
print(term % MOD)
return
# Else, compute sum S, all_even, all_five
S = 0
all_even = True
all_five = True
for i in range(9):
digit = i + 1
cnt = c[i]
if cnt == 0:
continue
S += digit * cnt
if digit % 2 != 0:
all_even = False
if digit != 5:
all_five = False
# Compute g
g = 1
if S % 9 == 0:
g *= 9
elif S % 3 == 0:
g *= 3
if all_even:
g *= 2
if all_five:
g *= 5
print(g % MOD)
if __name__ == '__main__':
main()
lam6er