https://www.acmicpc.net/problem/1748
https://github.com/stellaluminary/Baekjoon
st = ''.join([str(i) for i in range(1, int(input())+1)])
print(len(st))
st = ''
for i in range(1, int(input())+1):
st += str(i)
print(len(st))
입력받는 n의 길이에 따른 수학적 계산을 통해 해결했다.
n = input()
length = len(n)
res = length * (int(n) - 10**(length - 1) + 1)
length -= 1
while length:
res += length * (10**length - 10**(length - 1))
length -= 1
print(res)
방법 3의 간소화
n = input()
res = 0
for i in range(1, len(n)):
res += 9 * 10**(i-1) * i
res += (int(n)-10**(len(n)-1)+1)*len(n)
print(res)