11254 - Consecutive Integers


Difficulty : easy

Solution Description :

Mathematics problem

Input: sum
We know sum = n/2 {2a+(n-1)*d }  Here, d=1
so, 2*sum = n (2a+n-1)
=> a = (2*sum + n - n^2)/2n

If you can find the value of n (n is maximum is possible) then the ans are a and (a+n-1)
maximum n can be sqrt(2*sum)

For find a, if 2*sum+n-n^2 is divisible by 2*n (Here n from sqrt(2*sum)  to 1)
use long long for calculation.