[hdu 6288]缺失的数据范围 精度特殊处理(2018女生赛

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_40307434/article/details/80517372
    /*
        hdu6288 by zhuhua
        比赛的时候又哇又t一下午
        回来终于a掉了,还是0s( •̀ ω •́ )y
        精度问题。如果爆炸的处理很重要。
        因为乘方始终容易爆所以特别注意44\45行那里的处理。
    */
    #include<bits/stdc++.h>
    using namespace std;
    typedef long long LL;
    LL a,b,k;

    LL quick_pow(LL x,LL y){
        LL res=1LL;
        while(y){
            if(y&1)res*=x;
            if(res>=k)return k+1;//这里光有这里没用,但是可以加速AC
            x*=x;
            y>>=1;
        }return res;
    }
    LL findx(LL mid){
        LL i=1LL,temp=2LL;
        while(temp<mid){
            temp*=2LL;
            i++;
        }
        return i;
    }
    int main(){
        int t;
        cin>>t;
        while(t--){
            scanf("%I64d%I64d%I64d",&a,&b,&k);
            LL l=1,r=pow(k,1.0/a),ans=l;
            while(l<=r){
                LL mid=(l+r)>>1;
                LL tt=findx(mid);
                LL sma=quick_pow(tt,b);

                //这里最重要没有就哇给你看
                LL big=k;
                LL orz=quick_pow(mid,a);
                if(orz<=0)big=-1;
                else big/=orz;

                if(sma<=big){
                    ans=mid;
                    l=mid+1;
                }
                else
                    r=mid-1;
            }
            printf("%I64d\n",ans);
        }
        return 0;
    }

猜你喜欢

转载自blog.csdn.net/qq_40307434/article/details/80517372
今日推荐