hdu6288 - 缺失的数据范围 - 二分

hdu6288 - 缺失的数据范围 - 二分 

思路:

思路倒是很简单,就是会爆……这时可以反着求,反正就是判断结果是不是<=k

就那k一直除,若是在过程中,得到的结果<1,则不成立

代码如下:

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<cmath>
#include<set>
#include<map>
#include<functional>
using namespace std;
#define ll long long

typedef pair<ll,int>P;
const ll INF=1e17+10;
const int N=100005,mod=1e9+7;
ll k;
int a,b;
bool judge(ll n){
    ll p=k;
    for(int i=1;i<=a;i++){
        p/=n;
        if(p<1)return false;
    }
    ll q=(ll)ceil(log2(n));
    if(q==0)return 1;
    for(int i=1;i<=b;i++){
        p/=q;
        if(p<1)return false;
    }
    return true;
}

int main(){
    int t;
    scanf("%d",&t);
    while(t--){
        scanf("%lld%lld%lld",&a,&b,&k);
        ll l=0,r=1e18;
        while(l+1<r){
            ll m=(l+r)>>1;
            if(judge(m))l=m;
            else r=m;
        }
        printf("%lld\n",l);
    }
}

 

相关文章:

  • 2021-12-24
  • 2021-07-08
  • 2021-08-19
  • 2021-10-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-17
  • 2021-09-16
  • 2022-12-23
  • 2022-12-23
  • 2021-06-20
  • 2022-01-25
相关资源
相似解决方案