Number
Time limit2sMemory limit1024 MB
Given ranges [a,b] and [c,d], find the smallest integer greater than ac that is not a product u*v with u in [a,b] and v in [c,d].
- Level
Hard8 of 10
- Topics
- Math, Number theory, Binary search, Greedy
- Solved
- No attempts yet
Problem
Given natural numbers , , , and , find the smallest natural number greater than that cannot be written as the product of two natural numbers and with and .
Input
The input file contains a single line with the natural numbers , , , and (, ).
Output
Print the number .