P3001 [USACO10DEC] Big Macs Around the World G
Description
Bessie is studying her favorite subject, Macroeconomics, in cowllege. For her final project, she will be presenting research on exchange rates between countries around the world.
In order to make her presentation more lively, she would like to show the relative prices of Big Macs around the world, despite their rather unsavory contents. To illustrate, suppose that Bessie would like to find smallest value of a Big Mac in a country given its value in some initial country and exchange rates from which other country's values can be calculated (as illustrated below):
```cpp
* A Big Mac is worth 60 dollars in the United States
* The exchange rate from US dollars to Canadian dollars is 0.2 Canadian dollars per US dollar
* The exchange rate from US dollars to British Pounds is 5.00 British Pounds per US Dollar
* The exchange rate from British Pounds to Canadian dollars is 0.5 Canadian dollars per British Pound
* The exchange rate between Canadian dollars to US dollars is 5.00 US dollars per Canadian dollar and Bessie would like to find the smallest possible value of a Big Mac in Canada that can be obtained by exchanging currencies. There are two ways:
* Going from US dollars directly to Canada dollars would yield a burger worth 60.00 US dollars * 0.2 Canadian dollars / US dollar = 12.00 Canadian dollars
* Going from US dollars to British Pounds to Canadian dollars would yield a burger worth 60.00 US$ * 5.00 GBP / 1 US$ * 0.5 C$ / 1 GBP = 150.00 C$ (Canadian dollars).
```
Bessie would choose the former option, since she would much rather pay 12.00 Canadian dollars instead of 150.00 Canadian dollars for a Big Mac in Canada.
Bessie has N (1
Input Format
Line 1: Five space-separated numbers: N, M, V, A, B
Lines 2..M+1: Three space-separated numbers: i, j, e\_ij
Output Format
Line 1: A single positive number, the price of the Big Mac, with absolute or relative error at most 10^-6. If there is no minimum, output 0.