816A Codeforces - Karen and Morning
Solution in c++
#include <bits/stdc++.h>
using namespace std;
string a,b;
int mn;
string plsm(string x)
{
if(x[1]<'9')x[1]++;
else if(x[1]=='9'&& x[0]<'5'){x[0]++;x[1]='0';}
else if(x[1]=='9'&& x[0]=='5'){x="00";}
return x;
}
string plsh(string x)
{
if(x=="23"){x="00";}
else if(x[1]=='9'&& x[0]<'2'){x[0]++;x[1]='0';}
else if(x[1]<'9'&& x[0]<='2'){x[1]++;}
return x;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
getline(cin,a,':');cin>>b;
while( a[0] != b[1] || a[1]!=b[0] )
{
mn++;
if(b=="59"){b="00";a=plsh(a);continue;}
b=plsm(b);
}
cout<<mn;
return 0;
}
0 التعليقات:
إرسال تعليق