Binary search not computing

Hello, this was a binary search question I am trying to solve:
https://community.topcoder.com/stat?c=problem_statement&pm=3561&rd=6519

I implemented this code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#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


using namespace std;

long long binsearch(long long c, long long time){

long long low = 1, high = 2*INF, mid;
while(low <= high){
    mid = (low+high) >> 1;
    long long x = c * mid * log2(mid);
    if(x == time) return mid;
    else if(x > time)
        high = mid;
    else if(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
Last edited on
long long low = 1, high = 2*INF, mid;

if(x == time) return mid;
those are your most egregious errors
@ne555 what's wrong about them ?
Topic archived. No new replies allowed.