Infinite Power
Practice
3.7 (562 votes)
Binary search algorithm
Ad Hoc
Easy Medium
Ready
Depth First search
Approved
Problem
11% Success 4813 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Everyone is now in search for power! Some people think that some numbers have large powers so they use them a lot. After some search, Omar tried on many numbers to explore their powers, so now he know the numbers with infinite power!

The numbers with infinite powers are really easy to find, they are numbers which have all their digits as even numbers, so \(24\) has infinite power but \(12\) doesn't have infinite power.

But now there are only small amount of infinite power numbers. So Omar starts again searching about numbers with large (but not infinite) powers. He found out that power of a number (N) is equal to division of absolute difference between N and the number with infinite number not less than N over absolute difference between N and the number with infinite number not greater than N.

So given a number, help Omar finding power of the number.

Input Format:
First line of the input is an integer (T), number of test cases.
For each test case an integer N is given in new line.

Output Format:
If the number has infinite power, output "Unlimited Power" (without quotes) in a separate line, otherwise output the required ratio (in the most simplified form) in a separate line.

Constraints:

  • \(1 \le T \le 10 ^ 6\)
  • \(1 \le N \le 10 ^ 9\)

Note: Large I/O files. Use faster input, output methods.

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:30
202 votes
Tags:
Easy-Medium
Points:30
21 votes
Tags:
MediumApprovedReadyMathematicsOpenProbability and Statistics
Points:20
63 votes
Tags:
ApprovedBasic ProgrammingEasyMathOpen