Packets
InterviewTime limit1sMemory limit128 MB
Given counts of 1x1 through 6x6 square tiles, find the minimum number of 6x6 parcels needed to pack them all.
- Level
Medium5 of 10
- Topics
- Greedy, Implementation, Math, Simulation
- Solved
- No attempts yet
Problem
A factory produces products that all have the same height and square bases of sizes , , , , , and . These products are always delivered to customers in square parcels that have the same height and a base of size . Because of shipping costs, both the factory and the customer want to minimize the number of parcels needed to deliver an order. Write a program that, for each order, finds the minimum number of parcels required.
Input
The input consists of several lines, each describing one order. Each order is given as six integers separated by single spaces, listing the number of products of each size in order from the smallest () to the largest (). The input ends with a line containing six zeros.
Output
For each order line (except the final line of six zeros), print a single line containing the minimum number of parcels into which that order can be packed.