← Back to topics
Topic

SimpleMath

M
MilosRadic
can someone tell me what are the limits for T cause i really doubt that this is solvable in pascal...for huge t u cannot even read in time...0.1 sec the last test case wont pass no matter what i do.
what is the guess for the number we should write
imo its sqrt(2*n)
A
Al3kSaNdaR
There is some kind of an formula for this task ( but this isn't the way I did it ) :

ReadLn ( X );

WriteLn ( Succ ( Trunc ( Sqrt ( Succ ( 8 * X ) ) / 2 - 0.5 ) ) );

M
MilosRadic
how did u do it my gues is sqrt(2*n) but still TLE on last...
A
Al3kSaNdaR
My solution :

Create array 1 3 6 10 15 21 . . .

Than binary search for number .
M
MilosRadic
hmmm well when u do sqrt(2*n) then it is either that or that minus 1 or 2 so only 2-3 checks for every n and that binary search would take longer but idk maybe sqrt takes too long?or perhaps cant solve it cause of pascal?
A
Al3kSaNdaR
Y Pascal's Sqrt is slow IMHO .
M
MilosRadic
:((((
MAKES ME WANNA LEARN C++:D
A
Al3kSaNdaR
LEARN IT, JOIN THE DARK SIDE YOUNG SKYWALKER . xDDDD
D
Dgleich
The answer isn't always very near sqrt(2N)...
M
MilosRadic
well the thing is the sqrt operation isnt even done in time...