The maximum value

4.2

9 votes
Basic Math, Algorithms, Math
Problem

For a provided integer k, find the maximum value of m+n, where 1m,nk and (n2nmm2)2=1.

Note: The answer can exceed the range of a 32-bit integer.

Input format

The only line of the input contains one integer k.

Output format

Print the maximum value of m+n, where 1m,nk and (n2nmm2)2=1.

Constraints

1k1018

 

Sample Input
2
Sample Output
3
Time Limit: 2
Memory Limit: 256
Source Limit:
Explanation

In the first test case k=2 , n=2 and m=1 satisfying the given condition and maximum value =2+1=3.

Editor Image

?