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 就好了,但是素数尽量 ...
随机推荐
- Dojo入门:增强的Ajax功能
随着Web技术的发展,RIA似乎已经成了主流,Ajax也随之成了不可或缺的部分.Ajax是异步的javascript和Xml,虽然现在很多交互的数据格式都不再严格的采用XML,但这种异步的操作却越 ...
- java:Oracle(Jdbc的封装)和HTML(登录,注册,个人信息界面)
1.Oracle Jdbc的封装: public class TestJdbc { // 把jdbc需要的属性,全部私有化 private static final String DRIVER = & ...
- GO——beego简单开发实例(二)
在新建项目成功之后我们可以做一个简单的动态增删查改. 1.在models文件夹下新建models.go,根据模型新建表 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 ...
- Pytorch笔记 (2) 初识Pytorch
一.人工神经网络库 Pytorch ———— 让计算机 确定神经网络的结构 + 实现人工神经元 + 搭建人工神经网络 + 选择合适的权重 (1)确定人工神经网络的 结构: 只需要告诉Pytorc ...
- Java基础之Volatile原理
原文链接: http://www.aoaoyi.com/archives/956.html 计算机在执行程序时,每条指令都是在CPU中执行的,而执行指令过程中,势必涉及到数据 的读取和写入.由于程序运 ...
- 转·带你用实例理解C语言回调函数
原文出处:https://segmentfault.com/a/1190000008293902?utm_source=tag-newest 前言: 如不懂函数指针,请先查阅关于函数指针内容的资料(h ...
- Shell编程、part3
本节内容 1. shell流程控制 2. for语句 3. while语句 4. break和continue语句 5. case语句 6. shell编程高级实战 shell流程控制 流程控制是改变 ...
- python的并发GIL 了解
gil 又称 global interpreter lock (全局解释器锁) #python 中一个线程对应于c语言中的一个线程 #gil使得同一个时刻只有一个线程在一个cpu上执行字节码,无法将 ...
- Python 正则匹配网页内的IP地址及端口号
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2017-08-30 20:38:23 # @Author : EnderZhou (z ...
- CentOS7 nginx 最简单的安装以及设置开机启动
1. 下载tar包. 2. 解压缩tar包 3. 安装必须的部分 yum包 yum install -y gcc pcre pcre-devel openssl openssl-devel gd gd ...