Accepted
代码
#include<bits/stdc++.h>
using namespace std;
long long f(long long n)
{
long long l=0,r=0x7fffffff,mid,s,p;
while(l!=r){
mid=(l+r)/2;
s=(long long)mid*(mid+1)/2;
if(s*2-1<n)l=mid+1;
else r=mid;
}
s=1ll*l*(l+1)/2;
p=l*2-1;
if(s*2-1-l>=n)p--;
return p;
}
int main()
{
long long n;
cin>>n;
cout<<f(n);
return 0;
}