Unknown Number
Time limit2sMemory limit128 MB
Given an interval's two endpoints and a divisor-remainder pair, determine whether exactly one integer in that range satisfies the modular condition and print it, or report the number as unknown.
- Level
Medium4 of 10
- Topics
- Math, Implementation, Number theory
- Solved
- No attempts yet
Problem
You must determine one integer.
You are given the following two pieces of information.
- The two endpoints of the integer interval where the number may lie
- The remainder y when the number is divided by the integer x; equivalently, the number can be written as qx + y for some integer q, with 0 <= y < |x|
If exactly one integer is possible from this information, output that integer. Otherwise, output that the number is unknown.
Input
The first line contains the two endpoints of the interval where the integer may lie.
The second line contains the divisor x and the remainder y.
Every number in the input is an integer between -2^31 and 2^31 - 1, inclusive.
Output
If the possible integer can be determined uniquely, output that integer. If it cannot be determined uniquely, output Unknwon Number.