版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/q451792269/article/details/80782800
题意:
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;
}