Jump to content

Coding Challenge 1


fake_Bezawada

Recommended Posts


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
Link to comment
Share on other sites

kadu akka for input 2 output 1 vundi choodu

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

 

 

​each test case contain N ..let N be 8 , if x is 2 then B is 2  …task anti to find smallest positive integral root---

x^2+Bx-N =0 , substitute all those values so 0 avtundi ….it means x=2 is the smallest positive integral root 

 

so output will be 2,if it is positive integral root  or else -1 if there is no positive integral roots.

Link to comment
Share on other sites

kadu akka for input 2 output 1 vundi choodu

arey question lo em undi ra.. 

means x=2 is the smallest positive integral root 

 

so output will be 2,if it is positive integral root  or else -1 if there is no positive integral roots.

 

output should be 2 for input 2

 

if its not a root then output should be -1

 
Link to comment
Share on other sites

×
×
  • Create New...