CF916A.Jamie and Alarm Snooze
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Jamie loves sleeping. One day, he decides that he needs to wake up at exactly hh: mm. However, he hates waking up, so he wants to make waking up less painful by setting the alarm at a lucky time. He will then press the snooze button every x minutes until hh: mm is reached, and only then he will wake up. He wants to know what is the smallest number of times he needs to press the snooze button.
A time is considered lucky if it contains a digit '7'. For example, 13: 07 and 17: 27 are lucky, while 00: 48 and 21: 34 are not lucky.
Note that it is not necessary that the time set for the alarm and the wake-up time are on the same day. It is guaranteed that there is a lucky time Jamie can set so that he can wake at hh: mm.
Formally, find the smallest possible non-negative integer y such that the time representation of the time x·y minutes before hh: mm contains the digit '7'.
Jamie uses 24-hours clock, so after 23: 59 comes 00: 00.
杰米喜欢睡觉。一天,他决定必须在恰好 hh:mm 时刻醒来。然而,他讨厌被叫醒,因此希望通过将闹钟设定在一个“幸运时间”来减轻起床的痛苦。之后,他将每隔 x 分钟按一次贪睡按钮,直到到达 hh:mm 时刻才真正醒来。他想知道:最少需要按多少次贪睡按钮?
一个时间被称为“幸运时间”,当且仅当其时间表示中包含数字 '7'。例如,13:07 和 17:27 是幸运时间,而 00:48 和 21:34 不是幸运时间。
注意:闹钟设定的时间与最终唤醒时间不一定在同一天。题目保证存在某个幸运时间,使得杰米能够恰好在 hh:mm 醒来。
形式化地,求最小的非负整数 y,使得 hh:mm 时刻往前推 x·y 分钟后所对应的时间(以标准时间格式表示)中包含数字 '7'。
杰米使用 24 小时制时钟,即 23:59 之后是 00:00。
输入格式
The first line contains a single integer x (1 ≤ x ≤ 60).
The second line contains two two-digit integers, hh and mm (00 ≤ hh ≤ 23, 00 ≤ mm ≤ 59).
第一行包含一个整数 x(1≤x≤60)。
第二行包含两个两位整数 hh 和 mm(00≤hh≤23,00≤mm≤59)。
输出格式
Print the minimum number of times he needs to press the button.
输出他需要按按钮的最少次数。
输入输出样例
输入#1
3 11 23
输出#1
2
输入#2
5 01 07
输出#2
0
说明/提示
In the first sample, Jamie needs to wake up at 11:23. So, he can set his alarm at 11:17. He would press the snooze button when the alarm rings at 11:17 and at 11:20.
In the second sample, Jamie can set his alarm at exactly at 01:07 which is lucky.
在第一个样例中,Jamie 需要在 11:23 起床。因此,他可以将闹钟设为 11:17。当闹钟在 11:17 响起时,以及在 11:20 再次响起时,他会按下贪睡按钮。
在第二个样例中,Jamie 可以恰好将闹钟设为 01:07,而这个时间是幸运时间。
输入解题思路,AI测评打分。不知道怎么写?