OZO'S EQUATIONS
Practice
0 (0 votes)
Mathematics
Medium
Open
Approved
Mathamatics
Problem
22% Success 654 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Ozo is making a project on mathematical equation given by his teacher, but he want to test the given equation, whether this equation contain any positive integral root or not. Because if equation does not contain integral root his project will give abnormal results and he will not able to submit his project on time.

                     Equation:   x^2 = N - Bx

where N is an integer, B is sum of digits of number x. Your task is to find smallest positive integral root of this equation.

INPUT

First line of Input contains no. of test cases T. Each test case contain "N".

OUTPUT

For each test case output smallest positive integral root of the equation or print -1 if there is no positive integral roots.

CONSTRAINTS

T<=10^5

1<=N<=8 * 10^18

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
4 votes
Tags:
Medium
Points:30
2 votes
Tags:
MathsPrimesMedium
Points:30
1 votes
Tags:
MathematicsMediumOpenApprovedMathamatics