#abc275g. G - Infinite Knapsack
G - Infinite Knapsack
Score : points
问题描述
有 种类型的物品,每种物品都有无限多个复制品。第 种物品的重量为 ,体积为 ,价值为 。
等级为 的高桥最多能携带总重量不超过 、总体积也不超过 的物品。在此条件下,他可以携带任意数量的同种物品,也可以选择不携带某些种类的物品。
令 表示等级为 的高桥能够携带的最大物品总价值。可以证明极限 存在。求这个极限值。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There are kinds of items, each with infinitely many copies. The -th kind of item has a weight of , a volume of , and a value of .
Level Takahashi can carry items whose total weight is at most and whose total volume is at most . Under this condition, it is allowed to carry any number of items of the same kind, or omit some kinds of items.
Let be the maximum total value of items Level Takahashi can carry. It can be proved that the limit exists. Find this limit.
Constraints
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer. Your output will be considered correct if the absolute or relative error from the judge's answer is at most .
Sample Input 1
2
100000000 200000000 100000000
200000000 100000000 100000000
Sample Output 1
0.6666666666666667
When , Takahashi can carry items whose total weight is at most and whose total volume is at most .
He can carry, for instance, one copy of the -st item and one copy of the -nd item. Then, the total value of the items is . This is the maximum achievable value, so .
It can also be proved that equals . Thus, the answer is .
Sample Input 2
1
500000000 300000000 123456789
Sample Output 2
0.2469135780000000
update @ 2024/3/10 11:35:50