1.题目

2.代码
from operator import index
def bubbleSort(arr):
for i in range(len(arr)):
for j in range(i+1,len(result)):
if result[i]>result[j]:
result[i],result[j] = result[j],result[i]
return arr
def getTreeCase(target,num1,num2,num3):
if num1+num2 > target:
return 1,1,0
elif num1+num3 > target:
return 1,0,1
elif num2+num3 > target:
return 0,1,1
else:
list = [num1,num2,num3]
coefficient = [0,0,0]
maxIndex = list.index(max(list))
coefficient[maxIndex]= target // max(list)
minIndex = list.index(min(list))
middleIndex = [i for i in range(3) if i not in [maxIndex,minIndex]][0]
coefficient[middleIndex] = target % max(list)//list[middleIndex]
coefficient[minIndex] = target % max(list)%list[middleIndex]//min(list) if (target % max(list)%list[middleIndex]//min(list))==0 else (target % max(list)%list[middleIndex]//min(list)+1)
return coefficient
def getNeededNum(target, num1, num2):
result1 = result2 = 0
if num1 == 0:
result2 = target // num2 if target % num2 == 0 else target // num2 + 1
result1 = 0
if num2 == 0:
result1 = target // num1 if target % num1 == 0 else target // num1 +1
result2 = 0
if num1 != 0 and num2 != 0:
if num1 >= num2 :
result1 = target // num1
result2 = target % num1 // num2 if (target % num1 % num2) == 0 else (target % num1 // num2 + 1)
if num1 < num2:
result2 = target // num2
result1 = target % num2 // num1 if (target % num2 // num1) == 0 else (target % num2 // num1 + 1)
return result1, result2
target = int(input())
good1 = list(map(int, input().split(' ')))
good2 = list(map(int, input().split(' ')))
good3 = list(map(int, input().split(' ')))
arr = [good1,good2,good3]
def getPrice(arr,targetNum):
result = []
for i in range(len(arr)):
if arr[i][0]== targetNum:
result.append(arr[i][1])
bubbleSort(result)
return result[0]
num1 = arr[0][0]
price1 = arr[0][1]
num2 = arr[1][0]
price2 = arr[1][1]
num3 = arr[2][0]
price3 = arr[2][1]
goodAndPrice = arr
numList = [num1,num2,num3]
mixList = [[num1,num2],[num1,num3],[num2,num3]]
threeList = [[num1,num2,num3]]
result = []
for ele in numList:
res = []
result1,result2 = getNeededNum(target,ele,0)
price = getPrice(goodAndPrice,ele)
res.append(result1*price)
result.append(*res)
bubbleSort(result)
print(result[0])