-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdem_chu_so.py
More file actions
30 lines (29 loc) · 787 Bytes
/
dem_chu_so.py
File metadata and controls
30 lines (29 loc) · 787 Bytes
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
# input
a = int(input())
t = int(input())
k = int(input())
# define to count k
def count_k(start, end):
value_return = 0
for minute in range(start, end + 1):
if minute // 10 == k:
value_return += 1
if minute % 10 == k:
value_return += 1
return value_return
# calculate number k in an hour
numkin1hour = count_k(0, 59)
remain = t - (59 - a + 1)
# check a + t in range 60 minutes
if a + t <= 60:
result = count_k(a, a + t)
elif (a + t) % 60 == 0:
result = numkin1hour * (a + remain) // 60
else:
# part 1: first remain
result = count_k(a, 59)
# part 2: count the number k in an hour
result += remain // 60 * numkin1hour
# part 3: result plus the last remain
result += count_k(0, remain % 60)
print(result)