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 就好了,但是素数尽量 ...
随机推荐
- Dart学习笔记-变量常量数据类型
变量和常量 1.变量的定义 main() { var t_str = 'hello world'; var t_num = 123456; String t_str2 = '你好,我很高兴'; int ...
- Report List 报表开发
1. Report List的输出定义 * ...NO STANDARD PAGE HEADING: 输出的报表不包含表头: * ...LINE-SIZE col : 输出的报表不包含表头: * .. ...
- hibernate 事务处理
Hibernate的事务处理:事务:* 事务就是逻辑上的一组操作,要么全都成功,要么全都失败!!! 事务特性:* 原子性:事务一组操作不可分割.* 一致性:事务的执行前后,数据完整性要保持一致.* 隔 ...
- 使用movielens数据集动手实现youtube推荐候选集生成
综述 之前在博客中总结过nce损失和YouTuBe DNN推荐;但大多都还是停留在理论层面,没有实践经验.所以笔者想借由此文继续深入探索YouTuBe DNN推荐,另外也进一步总结TensorFlow ...
- 第八周总结and实验
1.实验目的 理解异常的基本概念:掌握异常处理方法及熟悉常见异常的捕获方法. 2.实验要求 练习捕获异常.声明异常.抛出异常的方法.熟悉try和catch子句的使用.掌握自定义异常类的方法. 3.实验 ...
- SQL 生成表结构表数据脚本
数据库右击——>任务——>生成脚本——>选择表 ——>高级——>要编写脚本的数据的类型(架构和数据.仅限架构.仅限数据)
- 洛谷P1600 天天爱跑步——题解
题目传送 首先要考虑入手点.先考虑一个一个玩家处理,显然不加优化的话,时间复杂度是O(n)的.发现对于玩家路径上的点都有一个观察员,一个都不能忽视,看起来是很难优化了.在做题时,发现一个思路很难想,就 ...
- [题解][SHOI2013]超级跳马 动态规划/递推式/矩阵快速幂优化
这道题... 让我见识了纪中的强大 这道题是来纪中第二天(7.2)做的,这么晚写题解是因为 我去学矩阵乘法啦啦啦啦啦对矩阵乘法一窍不通的童鞋戳链接啦 层层递推会TLE,正解矩阵快速幂 首先题意就是给你 ...
- 设计模式之单例模式(Singleton Pattern)
单例模式是最简单的设计模式之一.属于创建型模式,它提供了一种创建对象的最佳方式.使应用中只存在一个对象的实例,并且使这个单实例负责所有对该对象的调用.这种模式涉及到一个单一的类,该类负责创建自己的对象 ...
- goods商品类