I can not detect an error in the code. Help me find the error (code below, after the task):

Laptops packed in boxes were brought to the warehouse, which has a rectangular parallelepiped shape. Each box also has a rectangular parallelepiped shape. According to the rules of storage boxes with laptops must be placed in stock with the following two conditions:

  • The sides of the boxes should be parallel to the sides of the warehouse.
  • When placed in a warehouse, it is allowed to place the box anywhere (with the previous condition), including on the other box, but all boxes must be oriented the same way (i.e. one box cannot be “standing” and the other “lying”)

Write a program that, by the size of the warehouse and the size of the box with a laptop> determines the maximum number of laptops that can be placed in the warehouse.

Input format

The program receives six natural numbers as input. The first three set the length, height and width of the warehouse. The following three set the length, height and width of the box with the laptop, respectively.

Output format

The program should display one number - the maximum number of laptops that can be placed in stock.

Examples

Тест 1 Входные данные: 100 200 300 1 2 3 Вывод программы: 1000000 Тест 2 Входные данные: 100 200 300 3 2 1 Вывод программы: 1000000 Тест 3 Входные данные: 100 100 1 2 2 2 Вывод программы: Тест 4 Входные данные: 7 7 7 3 3 3 Вывод программы: 8 
 a = int(input()) # while a != -1: b = int(input()) c = int(input()) x = int(input()) y = int(input()) z = int(input()) m1 = int(a // x) * int(b // y) * int(c // z) m2 = int(a // x) * int(b // z) * int(c // y) m3 = int(a // y) * int(b // a) * int(c // z) m4 = int(a // y) * int(b // z) * int(c // x) m5 = int(a // z) * int(b // a) * int(c // y) m6 = int(a // z) * int(b // y) * int(c // x) if a >= x and b >= y and c >= z: if m1 > m2 and m1 > m3 and m1 > m4 and m1 > m5 and m1 > m6: print(m1) elif m2 > m3 and m2 > m4 and m2 > m5 and m2 > m6: print(m2) elif m3 > m4 and m3 > m5 and m3 > m6: print(m3) elif m4 > m5 and m4 > m6: print(m4) elif m5 > m6: print(m5) else: print(m6) else: print(0) # a = int(input()) 
  • if a> = x and b> = y and c> = z is wrong, there may be other packaging methods, a to y, etc. I would just put the values ​​of m1-m6 into the array and use the standard sorting of Python and everything should be correct - user184868

2 answers 2

Hello! My solution, only on if.

 a1 = int(input()) b1 = int(input()) c1 = int(input()) x = int(input()) y = int(input()) z = int(input()) d1 = (a1 // x) * (b1 // y) * (c1 // z) d2 = (a1 // x) * (c1 // y) * (b1 // z) d3 = (b1 // x) * (c1 // y) * (a1 // z) d4 = (b1 // x) * (a1 // y) * (c1 // z) d5 = (c1 // x) * (a1 // y) * (b1 // z) d6 = (c1 // x) * (b1 // y) * (a1 // z) if d1 >= d2: d2 = d1 if d3 >= d4: d4 = d2 if d5 >= d6: d6 = d5 if d2 >= d4 and d2 >= d6: print(d2) elif d4 >= d6: print(d4) else: print(d6) 

    First problem:
    In 2 lines ( m3 = ... and m5 = ... ) instead of b // a you need to be b // x :

     m3 = int(a // y) * int(b // x) * int(c // z) m5 = int(a // z) * int(b // x) * int(c // y) 

    The second problem:
    Your program expects to enter 6 numbers in one line , and not 6 numbers in 6 lines.

    You can do it like this:

     inp = input() # ввод строки из 6 чисел lst = inp.split() # split() сделает список из 6 элементов a, b, c, x, y, z = map(int, lst) # map применит функцию int на каждый элемент списка lst 

    or - since the third line is too complicated, instead of it gradually

     а = int(lst[0]) b = int(lst[1]) c = int(lst[2]) x = int(lst[3]) y = int(lst[4]) z = int(lst[5]) 

    Note:

    Instead of a complex multi-line if command, it is possible to use the max() function, and the entire bash program will be reduced by

     inp = input() # ввод строки из 6 чисел lst = inp.split() # split() сделает список из 6 элементов a, b, c, x, y, z = map(int, lst) # map применит функцию int на каждый элемент списка lst m1 = int(a // x) * int(b // y) * int(c // z) m2 = int(a // x) * int(b // z) * int(c // y) m3 = int(a // y) * int(b // a) * int(c // z) m4 = int(a // y) * int(b // z) * int(c // x) m5 = int(a // z) * int(b // a) * int(c // y) m6 = int(a // z) * int(b // y) * int(c // x) print(max(m1, m2, m3, m4, m5, m6))