#K81587. Minimum Packs
Minimum Packs
Minimum Packs
Chef wants to buy at least \(N\) items in total. He has two types of packs available:
- The first store sells packs containing \(K\) items.
- The second store sells packs containing \(L\) items.
Determine the minimum number of packs required (buying from either store) so that the total number of items is at least \(N\). Formally, if Chef buys \(x\) packs of size \(K\) and \(y\) packs of size \(L\), then these packs satisfy:
[ x \times K + y \times L \geq N, ]
and your task is to minimize \(x+y\). You are given multiple test cases to solve.
inputFormat
The input is read from stdin
and is formatted as follows:
- The first line contains a single integer \(T\), representing the number of test cases.
- Each of the next \(T\) lines contains three space-separated integers \(N\), \(K\), and \(L\), where \(N\) is the target number of items, and \(K\) and \(L\) are the number of items in a pack from the first and second store respectively.
outputFormat
For each test case, output a single line containing the minimum number of packs Chef must buy so that the total number of items is at least \(N\). The output is written to stdout
.
4
10 3 2
15 4 5
7 5 3
8 6 7
4
3
2
2
</p>