Jump to content

Coding Challenge 1


Recommended Posts

Posted

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
Posted
SAMPLE INPUT
 
 
2
2
4
SAMPLE OUTPUT
 
 
1
-1

 

Posted

chusthe easy laage vundhi kani naku em ardakatla

 

evaraina easy ga simplified ga explain cheyyara please

Posted

Idi quadratic equation kada man..smallest integral root anta….so equation has to become zero

Posted

input 

 

2-x

2-B

8-N

 

 

 

2 is a smallest integral root

Posted

input

2-x
2-B
8-N



2 is a smallest integral root

kadu akka for input 2 output 1 vundi choodu
Posted

itta mosam chesthe chepdamanukunnodiki kooda g lo current pass ai cheppadu

Posted

input

2-x
2-B
8-N



2 is a smallest integral root

Gongura pachadi lo leg vesav :(
Posted

itta mosam chesthe chepdamanukunnodiki kooda g lo current pass ai cheppadu

normal ga vunchite evadu cheppaledu
Posted

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.

Posted

Gongura pachadi lo leg vesav :(

kadu..its correct

Posted

normal ga vunchite evadu cheppaledu

vaste cheptadu..nuvvu ammai kathila undi ante rakundane chepestada?..lol seap tricks
Posted

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

 
×
×
  • Create New...