Zoo creatures
Practice
3.5 (20 votes)
Basic programming
Basic math
Algorithms
Number theory
Problem
43% Success 6153 Attempts 10 Points 1s Time Limit 256MB Memory 1024 KB Max Code

A zoo have two types of creatures, type A has \(a\) hands and type B has \(b\) hands. Spawn the smallest number of creatures so they can grab each other hands in the following conditions:

  • Each creature should only grab the hands of another creature type.
  • Each creature should grab with all of its hands.

What is the smallest number of creature needed?

Note: It is guaranteed that under the given conditions answer is unique.

Input  format

  • The first line contains \(t\) number of test cases .
  • Each of the next \(t\) lines contains two integers \(a_i, b_i\) denoting the number of type A creature hands and the number of type B creature hands.

Output format

The output contains \(t\) lines. For each test case, print two numbers \(ans1_i, ans2_i\), the number of type A creatures, and the number of type B creatures. Consider that \(ans1_i + ans2_i\) should be smallest possible.

Constraints

\(1 \leq t \leq 100 \space 000\)

\(1 \leq a_i, b_i \leq 10^9\)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:10
12 votes
Tags:
StringBasic ProgrammingImplementation
Points:10
181 votes
Tags:
Basic ProgrammingEasy
Points:10
156 votes
Tags:
Basic ProgrammingBasics of ImplementationEasyImplementation