Supersquare
Time limit1sMemory limit128 MB
For each n, find the smallest 2n-digit number whose full value and both n-digit halves are nonzero perfect squares.
- Level
Medium7 of 10
- Topics
- Math, Number theory, Brute force, Implementation
- Solved
- No attempts yet
Problem
A positive integer is a perfect square when some natural number satisfies .
Fix a positive integer . A -digit number, written without leading zeroes, is a supersquare when all three conditions hold:
- the whole -digit number is a perfect square;
- the number formed by its first (leftmost) digits is a perfect square;
- the number formed by its last (rightmost) digits is a perfect square.
The number formed by the last digits may contain leading zeroes, but it must not equal .
Among all -digit supersquares, print the smallest one. If no -digit supersquare exists, print the phrase NO SUPERSQUARE POSSIBLE instead.
Input
The first line contains the number of test cases ().
Each of the next lines contains one integer ().
Output
Print lines, one per test case, in the same order as the input.
For each , print the smallest -digit supersquare. If no such number exists, print NO SUPERSQUARE POSSIBLE on that line.