21 lines
425 B
Python
21 lines
425 B
Python
#!/usr/bin/env python3
|
|
|
|
from math import ceil
|
|
|
|
digs = 20
|
|
ln = 9**2 * digs + 1
|
|
mod = 10**9
|
|
|
|
|
|
sums = [0] * ln
|
|
count = [1] + [0] * (ln - 1)
|
|
|
|
for pw in range(digs):
|
|
for dsum in range(9**2 * pw, -1, -1):
|
|
for dig in range(1, 10):
|
|
sums[dsum + dig**2] += dig * 10**pw * count[dsum] + sums[dsum]
|
|
count[dsum + dig**2] += count[dsum]
|
|
|
|
|
|
print(sum(sums[i**2] for i in range(int(ceil(ln**0.5)))) % mod)
|