A. Karen and Morning
2017-06-18 00:41
387 查看
[b]A. Karen and Morning[/b]
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
Output
Input
Output
Input
Output
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.
[b]题解:
一个一个往前面推,每次判断时间是否回文就可以了。[/b]
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.
[b]题解:
一个一个往前面推,每次判断时间是否回文就可以了。[/b]
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<cstdlib> #include<algorithm> using namespace std; int cnt; bool judge(int a,int b) { if(a/10==b%10&&a%10==b/10)return 1; else return 0; } int main() { int a,b; scanf("%d:%d",&a,&b); if(judge(a,b)){cout<<0;return 0;} while(!judge(a,b)) { b++; cnt++; if(b==60){a++;b=0;} if(a==24){a=0;} } cout<<cnt; return 0; }
相关文章推荐
- 【codeforces 816A】Karen and Morning
- Codeforce A - Karen and Morning C - Sagheer and Crossroads E - Straight «A»
- codeforces A Karen and Morning 傻瓜模拟
- cf419 A Karen and Morning
- Karen and Morning
- CodeForce Round #479 A. Karen and Morning
- Karen and Morning
- A. Karen and Morning
- Codeforces 816A-Karen and Morning
- Karen and Morning
- Codeforces Round #419 (Div. 2) A. Karen and Morning(模拟)
- CF816A-Karen and Morning
- Codeforces Round #419 (Div. 2) A - Karen and Morning【水题】
- CF816B-Karen and Coffee
- [CF816B] Karen and Coffee(前缀和,思维)
- codeforces Karen and Coffee (区间贡献 思维)
- Codeforces Round #419 (Div. 2) C.Karen and Game 思维
- Codeforces Round #419 (Div. 2) D - Karen and Test(规律 杨辉三角)
- Codeforces Round #419 B. Karen and Test (思维 + 组合数 + 乘法逆元)
- Round#419 C Karen and Game