5.14快手笔试
做的研发C卷,AC了,求一个面试
一、发奖金
贪心 捣乱积分越低越前面,建设积分越低越前面, 因此两个乘积越低越前面
n = int(input()) a, b = map(int, input().split()) ls = a stack = [] temp = (a, b) for i in range(n): a, b = map(int, input().split()) stack.append((a, b)) # 捣乱积分越低越前面,建设积分越低越前面, 因此两个乘积越低越前面 stack = sorted(stack, key=lambda i:i[1]* i[0]) stack.insert(0, temp) ans = 0 for i in range(1, len(stack)): ans = max(ans, ls // stack[i][1]) ls *= stack[i][0] print(ans)
二、怪物下山
每行积分等于自己的积分和上面一行和左上方的积分相加的最大值,最后得出最后一行最大值就行
import sys n = int(input()) temp = list() for i in range(n): values = list(map(int, input().split())) temp.append(values) for i in range(1, len(temp)): for j in range(len(temp[i])): temp[i][j] += max(temp[i-1][j] if j < len(temp[i-1]) else 0, temp[i-1][j-1] if j-1 >= 0 else 0) print(temp) print(max(temp[-1]))
三、求m是不是n的整数次幂
m, n = map(int, input().split()) temp = n while n < m: n *= n while n > m: n = n // temp print(1 if n == m else 0)#快手春招##春招##笔试题目#