mirror of
https://github.com/codeflash-ai/codeflash-internal.git
synced 2026-05-04 18:25:18 +00:00
17 lines
429 B
Python
17 lines
429 B
Python
def problem_p03704(input_data):
|
|
def func(d, cnt9, cnt0):
|
|
|
|
if cnt9 < 1:
|
|
return d == 0
|
|
|
|
n = int("9" * cnt9 + "0" * cnt0)
|
|
|
|
return sum(
|
|
func(d + i * n, cnt9 - 2, cnt0 + 1) * (9 - abs(i) + 1 - (cnt0 < 1))
|
|
for i in range(-9, 10)
|
|
if abs(d + i * n) < n
|
|
)
|
|
|
|
D = eval(input_data)
|
|
|
|
return sum(func(D, i, 0) * (10 - i % 2 * 9) for i in range(1, 21))
|