Hey everyone, ↵
can someone tell me why this answer is wrong, I have checked the editorial as well, according to me it is same as written in editorial.↵
The problem is Mike and Chocolate thieves↵
My code:↵
↵
↵
↵
#include <bits/stdc++.h>↵
using namespace std;↵
int main(){↵
long long int m;↵
cin>>m;↵
long long int l=0,r=5e15;↵
long long int ans =-1;↵
while(l<=r){↵
long long int mid = l+(r-l)/2; // capacity↵
long long int count=0;↵
for(long long int k=2;k<=1e5;k++){↵
long long int a = mid/(k*k*k);↵
count+=a;↵
}↵
↵
if(count==m){↵
ans = mid;↵
r = mid-1;↵
}↵
else if(count>m) r = mid-1;↵
else{↵
l = mid+1;↵
}↵
}↵
cout<<ans<<endl;↵
↵
return 0;↵
}
can someone tell me why this answer is wrong, I have checked the editorial as well, according to me it is same as written in editorial.↵
The problem is Mike and Chocolate thieves↵
My code:↵
↵
↵
↵
#include <bits/stdc++.h>↵
using namespace std;↵
int main(){↵
long long int m;↵
cin>>m;↵
long long int l=0,r=5e15;↵
long long int ans =-1;↵
while(l<=r){↵
long long int mid = l+(r-l)/2; // capacity↵
long long int count=0;↵
for(long long int k=2;k<=1e5;k++){↵
long long int a = mid/(k*k*k);↵
count+=a;↵
}↵
↵
if(count==m){↵
ans = mid;↵
r = mid-1;↵
}↵
else if(count>m) r = mid-1;↵
else{↵
l = mid+1;↵
}↵
}↵
cout<<ans<<endl;↵
↵
return 0;↵
}