-
Notifications
You must be signed in to change notification settings - Fork 0
/
bookPage.py
80 lines (69 loc) · 1.51 KB
/
bookPage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# 11
# https://www.acmicpc.net/problem/1019
from sys import stdin
def calc(n, point):
while n > 0:
ans[n % 10] += point
n = n // 10
n = int(stdin.readline())
ans = [0] * 10
# def solution(a, b, count):
# #print('a, b', a, b)
# if a > b:
# return
# else:
# while b % 10 != 9 and a <= b:
# calc(b, count)
# b -= 1
#
# while a % 10 != 0 and a <= b:
# calc(a, count)
# a += 1
#
# if a == b:
# return
#
# for i in range(10):
# ans[i] += ((b // 10) - (a // 10) + 1) * (10 ** (count - 1))
#
# solution(a // 10, b // 10, count + 1)
#
# # tmp = 0
# # ctmp = 1
# # zero = 0
# # for _ in range(len(str(n)) - 1):
# # ans[0] += tmp
# # for i in range(1, 10):
# # ans[i] += (ctmp + tmp * 9)
# #
# # tmp = (ctmp + tmp * 9)
# # ctmp *= 10
#
# #solution(10 ** (len(str(n)) - 1), n, 1)
# solution(1, n, 1)
#
# for i in range(10):
# print(ans[i], end=' ')
point = 1
start = 1
while(start <= n):
#print(start, n)
while(n % 10 != 9 and start <= n):
calc(n, point)
n -= 1
#print('n',n)
if n < start:
break
while start % 10 != 0 and start <= n:
calc(start, point)
start += 1
#print('start', start)
start //= 10
n //= 10
#print(n, start)
#print((n - start + 1) * point)
for i in range(10):
ans[i] += ((n - start + 1) * point)
point *= 10
for i in range(10):
print(ans[i], end=' ')