Integer Rectangles
Time limit1sMemory limit128 MB
Find the smallest wide integer rectangle larger than the given one when ordered by diagonal length and then height.
- Level
Easy3 of 10
- Topics
- Brute force, Math
- Solved
- No attempts yet
Problem
A rectangle whose height and width are both natural numbers is called an integer rectangle. An integer rectangle whose width is larger than its height () is called a wide integer rectangle.
Two wide integer rectangles are compared in this order.
- The one with the shorter diagonal is smaller.
- If the two diagonals have the same length, the one with the smaller height is smaller.
Given one wide integer rectangle, write a program that finds the smallest wide integer rectangle larger than it.
Input
The input consists of several test cases. There are at most 100 test cases. Each test case is one line containing the height and the width of a wide integer rectangle, separated by a space.
and are larger than 0 and at most 100, and is larger than .
The last line of the input contains two zeros.
Output
For each test case, print on one line the height and the width of the smallest wide integer rectangle larger than the given one, separated by a space. These values do not exceed 150.