#P2502. [HAOI2006] 旅行
[HAOI2006] 旅行
Description
Z Town is a picturesque place that attracts tourists from all over. There are scenic spots near Z Town (numbered ), connected by roads. All roads are bidirectional, and there may be multiple roads between two spots.
Perhaps to protect local tourism resources, Z Town has a peculiar rule: for a given road , any vehicle traveling on that road must have speed .
Frequent speed changes make tourists uncomfortable, so when traveling from one spot to another, everyone wants to choose a route that minimizes the ratio between the maximum and minimum speeds during the trip, i.e., the most comfortable route.
Input Format
The first line contains two positive integers .
Each of the next lines contains three positive integers . This means there is a bidirectional road between spots and , and vehicles must travel at speed on that road.
The last line contains two positive integers , asking for the path from spot to spot with the smallest ratio of maximum to minimum speeds. and are not the same.
Output Format
If there is no path from to , output IMPOSSIBLE. Otherwise, output a number representing the minimal speed ratio. If necessary, output a reduced fraction.
4 2
1 2 1
3 4 2
1 4
IMPOSSIBLE
3 3
1 2 10
1 2 5
2 3 8
1 3
5/4
3 2
1 2 2
2 3 4
1 3
2
Hint
For of the testdata, , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号