#P4308. [CTSC2011] 幸福路径
[CTSC2011] 幸福路径
Description
There is a directed graph with vertices , and the weight of vertex is .
An ant starts from a given starting vertex and crawls along the edges of . Initially, its stamina is . Each time it traverses an edge, its stamina is multiplied by , where is a given positive constant less than . When the ant reaches a vertex, its happiness is the product of its current stamina and the weight of that vertex.
We denote the total happiness along the crawling path by . Clearly, for different crawling paths, the value of may differ. Xiao Z is interested in the maximum possible value of . Can you help compute it? Note that the length of the ant’s path may be infinite.
Input Format
Numbers on each line are separated by a single space.
The first line contains two positive integers , the number of vertices and edges in .
The second line contains non-negative real numbers, representing the vertex weights .
The third line contains a positive integer , the given starting vertex.
The fourth line contains a real number , the given positive constant less than .
Each of the next lines contains two positive integers , indicating that is a directed edge of . Self-loops may exist, but there are no multiple edges.
Output Format
Output a single real number: the maximum possible value of , rounded to one decimal place.
5 5
10.0 8.0 8.0 8.0 15.0
1
0.5
1 2
2 3
3 4
4 2
4 5
18.0
Hint
For of the testdata, , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号