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,以省电.但有的 ...
随机推荐
- acm--1006
Problem Description The three hands of the clock are rotating every second and meeting each other ma ...
- mysql主从延迟复制
需求描述 正常情况下我们是不会有刻意延迟从库的需求的,因为正常的线上业务自然是延迟越低越好.但是针对测试场景,业务上偶尔需要测试延迟场景下业务是否能正常运行. 解决方案 针对这种场景mysql有一个叫 ...
- Linux进程地址空间 && 进程内存布局[转]
一 进程空间分布概述 对于一个进程,其空间分布如下图所示: 程序段(Text):程序代码在内存中的映射,存放函数体的二进制代码. 初始化过的数据(Data):在程序运行初已经对变量进行初始 ...
- WARNING: IPv4 forwarding is disabled. Networking will not work.
1:Test environment [root@docker-node1 ~]# cat /etc/redhat-release CentOS Linux release 7.5.1804 (Cor ...
- JSP/Servlet开发——第十一章 Ajax交互扩展
1. jQuery实现Ajax的方法: ●除了$.ajax()方法以外,jQuery还提供了其他多种更简单的 Ajax 实现方法,如$.get().$.post().$.getJSON().对象.lo ...
- Redis(三):Redis数据类型
Redis数据类型目录导航: Redis五大数据类型 哪里去获取Redis常见数据类型操作命令 Redis键(Key) Redis字符串(String) Redis列表(List) Redis集合(S ...
- MongoDB 4.0.6 Manual
General mongod options: -v [ --verbose ] [=arg(=v)] be more verbose (include multiple times for more ...
- 01 elasticsearch 概念理解
最近在看一套 es 的教学视频,以下笔记主要来自视频资源 Near Realtime(NRT):近实时,先说实时就是数据创建到查询时间在毫秒级或更少: 和实时不一样的是近实时数据在创建到查询最多需要n ...
- C语言Windows程序开发—MessageBox函数介绍【第01天】
(一)MessageBox函数的参数介绍: int MessageBox ( HWND hWnd, //弹出MessageBox对话框所属的窗口句柄 LPCTSTR lpText, //指向Messa ...
- 成都Uber优步司机奖励政策(3月23日)
滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...