#P4028. New Product
New Product
Description
LiM owns a handmade pastry shop. Because the pastries are both affordable and delicious, the shop has accumulated regular customers ( is prime).
Every time the shop launches a New Product, they make many items. All customers will support it in this way:
- Each customer buys the same quantity.
- They buy as much as possible.
The shop has workers. At the end of each minute, the total number of products becomes times the current total.
(Note: initially, there is one already-made New Product as a sample.)
After production is finished and the regular customers rush to buy (only these regular customers are considered):
- To take care of the workers, exactly items must remain.
Given the known conditions, please help LiM compute the minimal working time.
Input Format
There are lines.
The first line contains an integer , the number of New Products.
Lines to each contain three integers , , , as described above.
Output Format
For each New Product:
- If it is achievable, output the minimal number of minutes worked.
- If it is not achievable, output
Couldn't Produce!.
1
5 2 3
3
1
2 2 2
Couldn't Produce!
Hint
Sample 1 explanation: There are regular customers, the total multiplies by each minute, and there are workers. The minimum is minutes (produce items) to meet the requirement.
Sample 2 explanation:
There are regular customers, the total multiplies by each minute, and there are workers. Since no matter how long they work the leftover will always be , output Couldn't Produce!.
Notes:
- LiM is not a worker.
- For each New Product, the number of regular customers may differ.
Constraints:
- For of the testdata, and all values .
- For of the testdata, , all values , and is prime.
Translated by ChatGPT 5
京公网安备 11011102002149号