CF-816A

A. Karen and Morning
time limit per test
2 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output

Karen is getting ready for a new school day!

It is currently hh:mm, given in a 24-hour format. As you know, Karen loves palindromes, and she believes that it is good luck to wake up when the time is a palindrome.

What is the minimum number of minutes she should sleep, such that, when she wakes up, the time is a palindrome?

Remember that a palindrome is a string that reads the same forwards and backwards. For instance, 05:39 is not a palindrome, because 05:39 backwards is 93:50. On the other hand, 05:50 is a palindrome, because 05:50 backwards is 05:50.

Input

The first and only line of input contains a single string in the format hh:mm (00 ≤  hh  ≤ 23, 00 ≤  mm  ≤ 59).

Output

Output a single integer on a line by itself, the minimum number of minutes she should sleep, such that, when she wakes up, the time is a palindrome.

Examples
input
05:39
output
11
input
13:31
output
0
input
23:59
output
1
Note

In the first test case, the minimum number of minutes Karen should sleep for is 11. She can wake up at 05:50, when the time is a palindrome.

In the second test case, Karen can wake up immediately, as the current time, 13:31, is already a palindrome.

In the third test case, the minimum number of minutes Karen should sleep for is 1 minute. She can wake up at 00:00, when the time is a palindrome.

转换一下数字再对比即可

AC代码:

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 
 4 char t;
 5 int n,k;
 6 int ans=0;
 7 
 8 int check(int n,int k){
 9     if(k%10*10+k/10==n){
10         cout<<ans<<endl;
11         return 1;
12     }
13     return 0;
14 }
15 
16 int main(){
17     ios::sync_with_stdio(false);
18     cin>>n>>t>>k;
19     while(1){
20         if(check(n,k))
21         break;
22         k++;
23         if(k==60){
24             n++;
25             k=0;
26         }
27         if(n==24){
28             n=0;
29             k=0;
30         }
31         ans++;
32         //cout<<n<<" "<<k<<endl;
33     }
34     return 0;
35 } 
原文地址:https://www.cnblogs.com/Kiven5197/p/7278402.html