codeforces1217A - Creating a Character

有必要挂下提醒下,写了个巨蠢的判断,菜得真实

思路:判断一下str最小的能够比iq大的就好了,用二分查找找出

#include<bits/stdc++.h>
using namespace std;
typedef long long i64;
int main()
{
    ios::sync_with_stdio(false); cin.tie(0),cout.tie(0);
    int T,str,iq,exp;      cin>>T;
    while(T--)
    {
        cin>>str>>iq>>exp;
        int l = 0,r = exp;
        while(l<=r)
        {
            int mid = (l + r) >> 1;
            if(str + mid > iq + exp - mid)
                r = mid - 1;
            else
                l = mid + 1;
        }
        cout<< exp - l + 1 <<'\n';
    }   
}

  

上一篇:codeforce B. Creating the Contest


下一篇:windows下安装Redis第一次启动报错:Creating Server TCP listening socket 127.0.0.1:6379: bind: No error