Time
InterviewTime limit1sMemory limit256 MB
Count how many clock times from 00:00:00 through N:59:59 contain the digit K at least once.
- Level
Easy2 of 10
- Topics
- Brute force, Implementation, Simulation, String matching
- Solved
- No attempts yet
Problem
Given integers N and K, write a program that counts how many times between 00:00:00 and N:59:59 contain at least one occurrence of the digit K. Times are read on a digital clock and are distinguished only by seconds.
For example, when K=3, the following times each contain at least one 3 and therefore must be counted.
- 23:00:00
- 07:08:33
On the other hand, the following times contain no 3 and therefore must not be counted.
- 15:02:55
- 18:27:45
Input
The first line contains integers N and K, separated by a space. (0≤N≤23, 0≤K≤9)
Output
Print the number of times between 00:00:00 and N:59:59 that contain at least one occurrence of the digit K.