A. Karen and Morning

Codeforces
IDCF816A
Time2000ms
Memory512MB
Difficulty
brute forceimplementation
English · Original
Chinese · Translation
Formal · Original
Karen is getting ready for a new school day! <center>![image](https://espresso.codeforces.com/8a2b710021d55bf4b4ee879bfa15914bf89c5da3.png)</center>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. [samples] ## 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.
Karen 正在为新的一天做准备! 当前时间是 _hh:mm_,采用 24 小时制。正如你所知,Karen 喜欢 _回文数_,她认为在时间是回文时醒来是好运的象征。 她最少需要睡多少分钟,才能在醒来时时间是一个回文? 记住,回文是一个正读和反读都相同的字符串。例如,_05:39_ 不是回文,因为 _05:39_ 反过来是 _93:50_。而 _05:50_ 是回文,因为 _05:50_ 反过来仍然是 _05:50_。 输入的第一行且唯一一行包含一个格式为 _hh:mm_ 的字符串(#cf_span[00 ≤ ] _hh_ #cf_span[ ≤ 23],#cf_span[00 ≤ ] _mm_ #cf_span[ ≤ 59])。 请输出一个单独的整数,表示她最少需要睡的分钟数,使得醒来时的时间是一个回文。 在第一个测试用例中,Karen 最少需要睡 #cf_span[11] 分钟。她可以在 _05:50_ 醒来,此时时间是回文。 在第二个测试用例中,Karen 可以立即醒来,因为当前时间 _13:31_ 已经是回文。 在第三个测试用例中,Karen 最少需要睡 #cf_span[1] 分钟。她可以在 _00:00_ 醒来,此时时间是回文。 ## Input 输入的第一行且唯一一行包含一个格式为 _hh:mm_ 的字符串(#cf_span[00 ≤ ] _hh_ #cf_span[ ≤ 23],#cf_span[00 ≤ ] _mm_ #cf_span[ ≤ 59])。 ## Output 请输出一个单独的整数,表示她最少需要睡的分钟数,使得醒来时的时间是一个回文。 [samples] ## Note 在第一个测试用例中,Karen 最少需要睡 #cf_span[11] 分钟。她可以在 _05:50_ 醒来,此时时间是回文。在第二个测试用例中,Karen 可以立即醒来,因为当前时间 _13:31_ 已经是回文。在第三个测试用例中,Karen 最少需要睡 #cf_span[1] 分钟。她可以在 _00:00_ 醒来,此时时间是回文。
**Definitions** Let $ t = \text{hh}:\text{mm} $ be the current time in 24-hour format, where $ \text{hh} \in \{0, 1, \dots, 23\} $, $ \text{mm} \in \{0, 1, \dots, 59\} $. Let $ T(m) $ denote the time $ m $ minutes after $ t $, represented as a 4-digit string $ \text{HHMM} $, with leading zeros (i.e., $ \text{HH} \in \{00, \dots, 23\} $, $ \text{MM} \in \{00, \dots, 59\} $). **Constraints** 1. $ 0 \leq \text{hh} \leq 23 $ 2. $ 0 \leq \text{mm} \leq 59 $ 3. $ T(m) $ must be a valid time: $ \text{HH} \in [0, 23] $, $ \text{MM} \in [0, 59] $ **Objective** Find the minimum non-negative integer $ m $ such that $ T(m) $ is a palindrome, i.e., the string $ \text{HHMM} $ satisfies: $$ \text{HHMM}[0] = \text{HHMM}[3] \quad \text{and} \quad \text{HHMM}[1] = \text{HHMM}[2] $$
Samples
Input #1
05:39
Output #1
11
Input #2
13:31
Output #2
0
Input #3
23:59
Output #3
1
API Response (JSON)
{
  "problem": {
    "name": "A. Karen and Morning",
    "description": {
      "content": "Karen is getting ready for a new school day! <center>![image](https://espresso.codeforces.com/8a2b710021d55bf4b4ee879bfa15914bf89c5da3.png)</center>It is currently _hh:mm_, given in a 24-hour format.",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 524288
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF816A"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Karen is getting ready for a new school day!\n\n<center>![image](https://espresso.codeforces.com/8a2b710021d55bf4b4ee879bfa15914bf89c5da3.png)</center>It is currently _hh:mm_, given in a 24-hour format....",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "Karen 正在为新的一天做准备!\n\n当前时间是 _hh:mm_,采用 24 小时制。正如你所知,Karen 喜欢 _回文数_,她认为在时间是回文时醒来是好运的象征。\n\n她最少需要睡多少分钟,才能在醒来时时间是一个回文?\n\n记住,回文是一个正读和反读都相同的字符串。例如,_05:39_ 不是回文,因为 _05:39_ 反过来是 _93:50_。而 _05:50_ 是回文,因为 _05:50_ 反过...",
      "is_translate": true,
      "language": "Chinese"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ t = \\text{hh}:\\text{mm} $ be the current time in 24-hour format, where $ \\text{hh} \\in \\{0, 1, \\dots, 23\\} $, $ \\text{mm} \\in \\{0, 1, \\dots, 59\\} $.  \nLet $ T(m) $ denote the t...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments