Last night in a contest I wrote this part of a code…
This is the problem
This is my solving function :
void solve(){
ll n;
cin>>n;
ll r= n - floor( sqrtl ( n ));
cout<<r<<endl;
}
And very strangely I was getting TLE…there was nothing else than this function in the code which might result in Time Complexity increase.
When I replaced endl with “\n” then it worked perfectly fine.
Any knowledge is welcome… Thanks