#include <bits/stdc++.h>
#define fl(n) for(int i = 0; i < n; i++)
#define ll long long
#define nl endl
#define pb push_back
#define mp make_pair
#define PII pair<int,int>
#define EPS 1e-9
#define INF 1e9
usingnamespace std;
longlong binsearch(longlong c, longlong time){
longlong low = 1, high = 2*INF, mid;
while(low <= high){
mid = (low+high) >> 1;
longlong x = c * mid * log2(mid);
if(x == time) return mid;
elseif(x > time)
high = mid;
elseif(x <= time){
low = mid;
}
}
return mid;
}
int main()
{
int c , time;
cin >> c >> time;
cout << binsearch(c, time);
return 0;
}
I tried all input examples and they all work except for:
1
2000000000
and idk why. it takes too long to compute and it doesn't seem to reach a point where it'll compute it any time soon haha. what is wrong with my implementation?
PS: dont wonder why i used long long instead of ll in my define macros but i just wanted alot of blue in the code :D