链接:

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(笨比题目)的更多相关文章

  1. CodeForces 916A Jamie and Alarm Snooze (水题)

    题意:给定一个数字n,和一个时间,问你每次可以把当前时间往回调n分钟,然后调多少次后时间中包含数字7. 析:直接模拟就好,从当前分钟向后调,注意调成负数的情况就好.很简单. 代码如下: #pragma ...

  2. 【Codeforces Round #457 (Div. 2) A】 Jamie and Alarm Snooze

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 暴力往前走x分钟就好. 直到出现7为止. [代码] #include <bits/stdc++.h> using nam ...

  3. Jamie and Alarm Snooze

    Description Jamie loves sleeping. One day, he decides that he needs to wake up at exactly hh: mm. Ho ...

  4. CF916A Jamie and Alarm Snooze 题解

    Content 令一个时间为幸运时间,当且仅当该时间中包含数字 \(7\). 小 J 很懒,他决定在 \(h\) 时 \(m\) 分起床,于是他将闹钟设定在一个很幸运的时间,并通过按一次按钮以多睡 \ ...

  5. 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 ...

  6. Codeforces 916C - Jamie and Interesting Graph

    916C - Jamie and Interesting Graph 思路:构造. 对于1到n最短路且素数,那么1到n之间连2 对于最小生成树,找一个稍微大点的素数(比1e5大)构造一个和为这个素数的 ...

  7. Codeforces 916E Jamie and Tree (换根讨论)

    题目链接  Jamie and Tree 题意  给定一棵树,现在有下列操作: $1$.把当前的根换成$v$:$2$.找到最小的同时包含$u$和$v$的子树,然后把这棵子树里面的所有点的值加$x$: ...

  8. 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 ...

  9. CodeForces 916C Jamie and Interesting Graph (构造)

    题意:给定两个数,表示一个图的点数和边数,让你构造出一个图满足 1-  n 的最短路是素数,并且最小生成树也是素数. 析:首先 1 - n 的最短路,非常好解决,直接 1 连 n 就好了,但是素数尽量 ...

随机推荐

  1. SAE Django如何禁止外部IP访问

    在SAE上基于Django搭建的Web工程有时需要禁止来自某些特定IP地址的访问请求. 例如一个为搭建在SAE的其他项目提供服务的内部工程,可以设置为只允许SAE内部的IP地址访问,从而提高项目的安全 ...

  2. Buffer对象与JSON对象相互转换

    > buffer=new Buffer('换汤不换药');<Buffer e6 88 91 e7 88 b1 e4 bd a0 ef bc 8c e7 89 a9 e7 90 86> ...

  3. junction 文件夹做连接到别的分区

    加载连接 C:\>junction "C:\Docume~1\Admini~1\LocalS~1\Applic~1\360Chr~1\Chrome\UserDa~1\Default&q ...

  4. Akka系列(七):Actor持久化之Akka persistence

    前言.......... 我们在使用Akka时,会经常遇到一些存储Actor内部状态的场景,在系统正常运行的情况下,我们不需要担心什么,但是当系统出错,比如Actor错误需要重启,或者内存溢出,亦或者 ...

  5. 【2019CSP-S游记】咕了好久了撒

    对,证书已经发下来了,我才想起来写游记(虽然我个蒟蒻明明就是在写反思) 终于和父母商议好了以后怎么办,顺带找了一下班主任,在机房的电脑敲出来的(我来找教练,然后完全没找着,淦) 79分,众所周知CCF ...

  6. 洛谷 U78696 图书馆馆长的考验 题解

    题面 1. 图书馆馆长的考验(library) 红魔馆的拥有者蕾米莉亚的好友帕秋莉是红魔馆的大图书馆的馆长.擅长操纵五行,名言是“万物都有属性.所谓的属性,和弱点是一样的”. 一天,因为魔理沙看了神之 ...

  7. shell with hadoop

    shell 命令操作 hadoop 之前多少提及过,这里做个总结. shell with hdfs 基本命令 bin/hadoop fs 大于下面的命令 bin/hdfs dfs dfs 是 fs 的 ...

  8. str 小列题

    name = " aleX leNb "#2.有变量 完成如下操作: 移除 name 变量对应的值两边的空格,并输出处理结果 name=name.strip() print(nam ...

  9. RabbitMQ入门教程(十):队列声明queueDeclare

    原文:RabbitMQ入门教程(十):队列声明queueDeclare 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https:// ...

  10. ——HTTP状态码

    200 请求成功,请求所希望的响应头或数据体将随此返回 302 请求的资源现在临时从不同的URI响应请求,由于这样的重定向是临时的,客户端应当继续向原有地址发送以后的请求. 304 如果客户端发送了一 ...