Jamie and Alarm Snooze
Description
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 luckytime 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: mmcontains the digit '7'.
Jamie uses 24-hours clock, so after 23: 59 comes 00: 00.
Input
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).
Output
Print the minimum number of times he needs to press the button.
Sample Input
3
11 23
2
5
01 07
0
Hint
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.
题目意思:一个人想要在hh:mm时刻起床,而他想从在离起床时刻最近的一个带有数字7的时刻起,每x分钟按一次按钮,问一共按了多少次
解题思路:模拟即可,注意小时与分钟间的切换。
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
int n,h,m,count;
while(scanf("%d%d%d",&n,&h,&m)!=EOF)
{
count=;
while()
{
if(h==||h==||m%==)
{
break;
}
else
{
count++;
m=m-n;
if(m<)
{
m=m+;
h--;
}
if(h<)
{
h=h+;
}
}
}
printf("%d\n",count);
}
return ;
}
Jamie and Alarm Snooze的更多相关文章
- CodeForces 916A Jamie and Alarm Snooze (水题)
题意:给定一个数字n,和一个时间,问你每次可以把当前时间往回调n分钟,然后调多少次后时间中包含数字7. 析:直接模拟就好,从当前分钟向后调,注意调成负数的情况就好.很简单. 代码如下: #pragma ...
- 【Codeforces Round #457 (Div. 2) A】 Jamie and Alarm Snooze
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 暴力往前走x分钟就好. 直到出现7为止. [代码] #include <bits/stdc++.h> using nam ...
- CF916A Jamie and Alarm Snooze 题解
Content 令一个时间为幸运时间,当且仅当该时间中包含数字 \(7\). 小 J 很懒,他决定在 \(h\) 时 \(m\) 分起床,于是他将闹钟设定在一个很幸运的时间,并通过按一次按钮以多睡 \ ...
- CodeForces-916A-jamie and Alarm Snooze(笨比题目)
链接: https://vjudge.net/problem/CodeForces-916A 题意: Jamie loves sleeping. One day, he decides that he ...
- CCPC-Wannafly Summer Camp 2019 全记录
// 7.19-7.29 东北大学秦皇岛校区十天训练营,题目都挂在了Vjudge上.训练期间比较忙,没空更博总结,回来继续补题消化. Day1 这天授课主题是简单图论,节奏挺好,wls两小时理完图论里 ...
- Android中对闹钟Alarm的事件处理
之前的博文一直在持续分享Phone相关的知识也算是知识笔记,但在工作中难免遇到其他模块的一些问题,因此在解决这些问题的时候顺手将这些知识记录并分享出来.有些知识在不知道的时候会觉得非常难,当了解之后便 ...
- rtc关机闹钟2 Alarm manager
public void set(int type, long triggerAtMillis, long windowMillis, long intervalMillis, PendingInten ...
- setup notifier actions in aodh alarm
Aodh alarm NOTIFIER ==> alarm_actions URL: http://<host>/<action> NOTIFIER will resol ...
- Best Practices for Background Jobs_3 Managing Device Awake State之电源锁、Alarm、WakefulBroadcastReceiver
http://developer.android.com/training/scheduling/index.html 当静置一个设备的时候,先会屏幕变暗,然后关闭屏幕,最后关闭CPU,以省电.但有的 ...
随机推荐
- Jmeter的实例应用
目标: 获取城市的天气数据: 第一步: 发送request 获取城市的城市代号http://toy1.weather.com.cn/search?cityname=上海 从这个请求的response ...
- Android 微信页面刷新问题
今天测试妹纸提了个bug,Android手机用微信打开测试页面,刷新功能无效.因为开发时懒,只验证了Ios手机无异常,没有注意打安卓这个问题. 我是直接用的window.location.reload ...
- UML类图介绍以及PlantUML使用方法
类的UML表示方法 UML介绍 类图,是UML(统一建模语言)中用于描述"类"以及"类与类"之间的示意图.它形象的描述出了系统的结构,帮助人们理解系统. 类图是 ...
- Elasticsearch 映射操作
一.创建 语法: PUT /索引库名称/_mapping/类型名称 { "properties": { "字段名": { "type": 类 ...
- Python文本和字符串常用操作
## 字符串分割 line = "This is my love!" fields = line.split(' ') print(fields) # ['This', 'is', ...
- laravel5.5源码阅读草稿——入口
laravel的启动需要通过路由.中间件.控制器.模型.视图最后出现在浏览器.而路由.中间件.模型,这些功能都有自己的类,比如Route::any().DB::table().$this->mi ...
- thinkphp5 部署到iis服务器url重写
thinkphp部署到iis服务器配置url重写的解决方法: 1.下载 url rewrite.下载地址:https://www.iis.net/downloads/microsoft/url-rew ...
- Python学习手册之正则表达式和元字符
在上一篇文章中,我们介绍了 Python 的数据封装.类方法.静态方法和属性函数,现在我们介绍 Python 的正则表达式和元字符.查看上一篇文章请点击:https://www.cnblogs.com ...
- ACM1000:A + B Problem
Problem Description Calculate A + B. Input Each line will contain two integers A and B. Process to ...
- Struts2获取Servlet的api的两种方式,解决ParameterAware过时的问题
servlet API通过ActionContext进行获取 Struts2对HttpServletRequest,HttpSession和ServletContext进行了封装,构造了3个Map对象 ...