HDU 6288

HDU 6288 - 缺失的数据范围 - 二分答案

题解

本题属于比较简单的二分答案题。可惜HDU不支持Python,要么用C++高精板子要么用Java。

Python实现

from math import log
from math import ceil
t = int(input())
while t > 0:
    a ,b ,k = map(int,input().split())
    l = 1
    r = k
    ans = 1
    while l < r:
        mid = (l+r)//2
        val = mid**a *(ceil(log(mid,2))) ** b
        if val > k:
            r = mid-1
        else: # val <= k
            l = mid + 1
            if mid > ans:
                ans = mid
    t -= 1
    print(ans)

---- suffer now and live the rest of your life as a champion ----
原文地址:https://www.cnblogs.com/popodynasty/p/13658309.html