#P2656. 采蘑菇
采蘑菇
Description
Xiaopang and ZYR are going to the ESQMS forest to pick mushrooms.
In the ESQMS forest, there are small thickets and paths. Each path is directed, connects two thickets, and has some mushrooms on it. When Xiaopang and ZYR traverse a path once, they can collect all the mushrooms on that path. Because the ESQMS forest is a magical fertile land, after the mushrooms on a path are picked, new mushrooms will grow on that path again, with the quantity equal to the original number of mushrooms multiplied by the path’s "recovery factor", then rounded down.
For example, if a path initially has mushrooms and its "recovery factor" is , then the numbers of mushrooms that can be collected on the first through fourth traversals are respectively.
Now, starting from thicket , find the maximum number of mushrooms they can collect.
Input Format
The first line contains two integers, and .
From the second line to the -th line, each line contains four numbers, representing the start thicket, the end thicket, the initial number of mushrooms, and the recovery factor of a path.
The -th line contains an integer .
Output Format
Output one line with a single integer, the maximum number of mushrooms that can be collected. It is guaranteed that the answer does not exceed .
3 3
1 2 4 0.5
1 3 7 0.1
2 3 4 0.6
1
8
Hint
For of the testdata, , .
For another of the testdata, all "recovery factors" are .
For of the testdata, , , with at most one decimal place, and .
Translated by ChatGPT 5
京公网安备 11011102002149号