So You Like Your Food Hot?
InterviewTime limit2sMemory limit512 MB
Given monthly profit and per-item profits for pita and pizza, find all nonnegative integer pairs whose profit equals the total and list them by pita count, or none.
- Level
Medium5 of 10
- Topics
- Math, Number theory, Brute force, Implementation
- Solved
- No attempts yet
Problem
Peter is co-owner of the incredibly successful Pete and Pat's Pitas and Pizzas, and his sales are on fire! Unfortunately, so is his building, since carelessly laid delivery boxes were placed too close to Pete's famous wood burning pizza oven. After sifting through the remnants, one of the few things Pete is able to salvage is a ledger book, but the only thing he can make out on the charred pages is the profit he made during the last month. The insurance company would like to know how many pitas and how many pizzas Pete actually delivered over that period. Pete does recall how much profit he makes on each of these products, so he is pretty confident that he can determine how many of each were sold during the last month given the total profit. Well, perhaps "confident" is not the exact word Peter is looking for. "Clueless" is closer. Can you help Pete out? I'm sure there are some discount coupons in it for you, or at least a really cheap price on a used pizza oven.
Input
Input consists of a single line containing 3 values pt p1 p2, where 0 ≤ pt ≤ 10 000.00 is the profit for the month and 0 < p1, p2 ≤ 100.00 are the profits Pete makes on a pita (p1) and on a pizza (p2). All values are in dollars and cents.
Output
Display two integers: the number of pitas sold and the number of pizzas sold so that the total profit equals the value given. If there is more than one combination of pitas and pizzas that give the specified profit, list them all, one combination per line, listing the combination with the smallest number of pitas first, then the combination with the second smallest number of pitas, and so on. If there are no combinations of pizza and pita sales that realize the profit, output none.