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)
#快手春招##春招##笔试题目#
全部评论
强👍👍👍 第一题没看懂,麻了麻了
点赞 回复 分享
发布于 2022-05-14 21:07

相关推荐

评论
3
6
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务