时间复杂度和算法加速

时间:2020-08-07 17:56:12

标签: python python-3.x time time-complexity space-complexity

代码花费超过1秒钟的时间

约束1≤T≤10^ 51≤P≤10^ 51≤H≤10^ 6

如何减少代码花费的时间

# cook your dish here
def check(h, p):
    while p>0:
        if h<=0:
            return 1
        if h-p>=0:
            h = h-p
        else:
            h=0
        p = p/2
        # print(h,p)
    return 0
for _ in range(int(input())):
    h, p = map(int, input().split())
    print(check(h,p))

0 个答案:

没有答案