Math is a Physical Education Subject 3
InterviewTime limit1sMemory limit1024 MB
Given the concatenation of all integers from A to B, recover A and B, choosing the smallest A if several pairs fit.
- Level
Medium4 of 10
- Topics
- String, Brute force, Implementation, Math
- Solved
- No attempts yet
Problem
Ihwan is a genius five-year-old baby living in the era of the Fourth Industrial Revolution. One day, after discovering Ihwan's genius, his kindergarten teacher gave him the following problem.
What is the sum of all integers from to , inclusive?
Ihwan is a genius, but he is still a baby and does not really know what addition is. The next day, Ihwan wrote all the integers from to , inclusive, in increasing order with no spaces in his notebook. For example, when and , the answer Ihwan wrote down is 456789101112131415161718192021.
Ihwan is a genius with exceptional obsession over assignments, but his teacher is not. In fact, Ihwan's teacher even forgot what the two numbers he called yesterday were. The only information the teacher remembers is that both and were integers between and , inclusive, and that naturally was less than or equal to .
Given the sequence of digits Ihwan wrote down, can you find the two numbers the teacher called?
Input
The first line gives the string representing the answer Ihwan wrote down. consists only of digits (0123456789), and its length is between and , inclusive.
Output
Print the two integers and that Ihwan's teacher called, separated by a space. If more than one answer is possible, print the one with the smallest .
Because Ihwan always writes the correct answer, only inputs for which an answer satisfying the problem's conditions exists are given.