CodeForces-916A-jamie and Alarm Snooze(笨比题目)
链接:
https://vjudge.net/problem/CodeForces-916A
题意:
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.
思路:
开始以为按几下可以变到7...没想到是往前,还只能往前.
代码:
#include <bits/stdc++.h>
using namespace std;
bool Solve(int h, int m)
{
while (h)
{
if (h%10 == 7)
return true;
h /= 10;
}
while (m)
{
if (m%10 == 7)
return true;
m /= 10;
}
return false;
}
int main()
{
int x, h, m, h1, m1;
cin >> x >> h >> m;
h1 = h, m1 = m;
int cnt = 0, cnt1 = 0;
while (!Solve(h1, m1))
{
m1 -= x;
if (m1 < 0)
h1--, m1 = 60+m1;
if (h1 < 0)
h1 = 24+h1;
cnt1++;
}
cout << cnt1 << endl;
return 0;
}
CodeForces-916A-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 ...
- Jamie and Alarm Snooze
Description Jamie loves sleeping. One day, he decides that he needs to wake up at exactly hh: mm. Ho ...
- CF916A Jamie and Alarm Snooze 题解
Content 令一个时间为幸运时间,当且仅当该时间中包含数字 \(7\). 小 J 很懒,他决定在 \(h\) 时 \(m\) 分起床,于是他将闹钟设定在一个很幸运的时间,并通过按一次按钮以多睡 \ ...
- CodeForces 916E Jamie and Tree(树链剖分+LCA)
To your surprise, Jamie is the final boss! Ehehehe. Jamie has given you a tree with n vertices, numb ...
- Codeforces 916C - Jamie and Interesting Graph
916C - Jamie and Interesting Graph 思路:构造. 对于1到n最短路且素数,那么1到n之间连2 对于最小生成树,找一个稍微大点的素数(比1e5大)构造一个和为这个素数的 ...
- Codeforces 916E Jamie and Tree (换根讨论)
题目链接 Jamie and Tree 题意 给定一棵树,现在有下列操作: $1$.把当前的根换成$v$:$2$.找到最小的同时包含$u$和$v$的子树,然后把这棵子树里面的所有点的值加$x$: ...
- codeforces 916E Jamie and Tree dfs序列化+线段树+LCA
E. Jamie and Tree time limit per test 2.5 seconds memory limit per test 256 megabytes input standard ...
- CodeForces 916C Jamie and Interesting Graph (构造)
题意:给定两个数,表示一个图的点数和边数,让你构造出一个图满足 1- n 的最短路是素数,并且最小生成树也是素数. 析:首先 1 - n 的最短路,非常好解决,直接 1 连 n 就好了,但是素数尽量 ...
随机推荐
- Java List集合 遍历 四种方式(包含 Lambda 表达式遍历)
示例代码如下: package com.miracle.luna.lambda; import java.util.ArrayList; import java.util.List; /** * @A ...
- spring aop影响dubbo返回值问题解决
问题描述: dubbo服务已经注册,客户端调用提供者服务返回值为空.(考虑动态代理.aop的返回值影响,dubbo基于spring2.5.6.SEC03,本次开发使用的是spring4.3.8) 解决 ...
- LeetCode.1037-有效的回旋镖(Valid Boomerang)
这是小川的第387次更新,第416篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第248题(顺位题号是1037).回旋镖是一组各不相同且不在一条直线上的三个点.给出三个点 ...
- LeetCode.1002-寻找共有字符(Find Common Characters)
这是悦乐书的第375次更新,第402篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第236题(顺位题号是1002).给定仅由小写字母组成的字符串A,返回列表中所有字符串都 ...
- 深入理解java:3. NIO 编程
I/O简介 I/O即输入输出,是计算机与外界世界的一个借口. IO操作的实际主题是操作系统. 在Java编程中,一般使用流的方式来处理IO,所有的IO都被视作是单个字节的移动,通过stream对象一次 ...
- vue-蒙层弹窗里的内容滚动。外层大页面禁止滚动
此需求 有两种方法,第一种,这种方法适用于,底层 和弹窗是两个平行的没有关系的两部分.重叠(https://blog.csdn.net/yuhk231/article/details/741717 ...
- mysql——视图——概念
二.视图 视图是一种虚拟的表,是从数据库中的一个或者多个表中导出来的表. 视图还可以从已经存在的视图的基础上定义. 数据库中只存放了视图的定义,并没有存放视图中的数据,这些数据存放在原来的表中. 使用 ...
- DataGridView中EnditCommit()调用之后,单元格的内容被全选了,每次输入都要鼠标点击定位到最后才能继续输入
因为某些需求,DataGridView在输入一次内容,就要调用ECommitEdit(DataGridViewDataErrorContexts.Commit)来将内容提交,但是这样做之后,控件就会当 ...
- Book - 《Python编程:从入门到实践》
Tag:看<Python编程:从入门到实践>学习笔记 数据类型相关: 字符串str 改变大小写(临时):title首字母大写,upper全大写,lower全小写 删除空白(临时):rstr ...
- 编辑器IDE之VSCode
很多时候面临换项目组,公司内部换等等,需要清除之前的权限,电脑更换等... 确实很烦人,所以记录也是给自己下次更加快速方便的使用 插件安装 个人常用的一些插件,发现好用的会更新 插件名 功能 vsco ...