IT校招全国统一模拟笔试(六月场)
程序员文章站
2022-03-27 08:32:34
...
IT校招全国统一模拟笔试(六月场)
编程题三道:(未完待续,题目忘了)
1、
2、
# 获取最低价格
def getMinPrice(num,price,x,y):
price_sum = 0
if num>=y:
if price>=x/y:
price_sum = x
return price_sum
if __name__== "__main__":
try:
while True:
# 输入
list = [int(i) for i in input("").split()]
arr = []
for i in range(list[1]):
tmp = [int(i) for i in input("").split()]
arr.append(tmp)
###########################################
sum_price = 0
sum_p = list[0]+1
person = []
for j in range(list[1]):
person.append(arr[j][1])
value = []
for j in range(list[1]): # 性价比
value.append(arr[j][0]/arr[j][1])
while sum_p>=min(person):
x = arr[value.index(min(value))][0]
y = arr[value.index(min(value))][1]
tmp1 = getMinPrice(sum_p,list[2],x,y)
sum_price += tmp1
sum_p -= arr[value.index(min(value))][1]
sum_price = sum_price + sum_p*list[2]
print(sum_price)
except:
pass
运行结果:
3、
推荐阅读