1379 and Cubes
Time limit1sMemory limit128 MB
Given a number S ending in 1,3,7 or 9 with up to 10 digits, find any integer x (no longer than S) whose cube's last digits exactly match S.
- Level
Medium6 of 10
- Topics
- Number theory, Math, Brute force
- Solved
- No attempts yet
Problem
You are given a number S. The last digit of S is one of 1, 3, 7, and 9. For every such S, there is always an integer x whose cube ends with S.
For each test case, find and print any integer x such that the ending digits of x^3 are exactly S, and the decimal length of x is at most the decimal length of S.
Input
The first line contains the number of test cases T.
Each of the next T lines contains one number S. The number S ends in one of 1, 3, 7, and 9, and has at most 10 digits.
Output
For each test case, print one integer x satisfying the condition, one per line.