Candies CodeForces - 991C(二分水题)

时间:2023-03-09 05:51:59
Candies CodeForces - 991C(二分水题)

就是二分暴力就好了

为什么要记下来 呵呵。。。。emm你说为什么。。。

行吧

好吧

我一直以为我的二分出问题了

原来不是 依旧很帅

统计的时候求的减了多少次  然后用次数乘了mid 这样做会使那个人获得的数量大于精确值。。我以为没事来。。还是太天真

#include <bits/stdc++.h>
using namespace std;
const int maxn = , INF = 0x7fffffff;
typedef long long LL;
LL n, k; int main()
{
scanf("%lld", &n);
if(n <= )
{
cout<< <<endl;
return ;
}
LL tmp = n;
LL l = , r = n; while(l <= r)
{
LL sum = ;
tmp = n;
LL mid = l + (r - l) / ;
while(tmp > )
{
LL t = min(mid, tmp);
tmp -= t;
tmp -= tmp / ;
sum += t;
}
if(sum >= (n+) / ) r = mid - ;
else l = mid + ;
}
cout<< l <<endl; return ;
}