1. 程式人生 > >A - Jamie and Alarm Snooze

A - Jamie and Alarm Snooze

這裡寫圖片描述

題意:

Jamie要在某一時刻起床,但希望在某一個含7的幸運時刻被鬧鐘吵醒,然後在恰好經過若干個x分鐘的小睡後到達該時刻。注意是before.
注意讀題。

題解:

模擬一下即可。

程式碼:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdlib>
using namespace std;

int main()
{
    int
x; int hh,mm; cin>>x; cin>>hh>>mm; int tmpm=mm; int tmph=hh; int cnt=0; for(;;) { if(tmpm%10==7||tmph%10==7) break; tmpm-=x;cnt++; if(tmpm<0) { tmpm+=60; tmph--; if(tmph<00) tmph+=24; } } cout
<<cnt<<endl; return 0; }