QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 1024 MB Total points: 100

#3731. Toll

الإحصائيات

In ICPCCamp, there are $n$ cities and $m$ unidirectional roads between cities. The $i$-th road goes from the $a_i$-th city to the $b_i$-th city. For each pair of cities $u$ and $v$, there is at most one road from $u$ to $v$.

As traffic in ICPCCamp is becoming heavier, toll of the roads also varies. At time $t$, one should pay $(c_i \cdot t + d_i)$ dollars to travel along the $i$-th road.

Bobo living in the $1$-st city would like to go to the $n$-th city. He wants to know the average money he must spend at least if he starts from city $1$ at $t \in [0, T]$. Note that since Bobo's car is super-fast, traveling on the roads costs him no time.

Formally, if $f(t)$ is the minimum money he should pay from city $1$ to city $n$ at time $t$, Bobo would like to find $$\frac{\int_0^{T} f(t) \mathrm{d}t}{T}.$$

Input

The input contains at most $30$ sets. For each set:

The first line contains $3$ integers $n, m, T$ ($2 \leq n \leq 10, 1 \leq m \leq n(n - 1), 1 \leq T \leq 10^4$).

The $i$-th of the following $m$ lines contains $4$ integers $a_i, b_i, c_i, d_i$ ($1 \leq a_i, b_i \leq n, a_i \neq b_i, 0 \leq c_i, d_i \leq 10^3$).

It is guaranteed that Bobo is able to drive from city $1$ to city $n$.

Output

A floating number denotes the answer. It will be considered correct if its absolute or relative error does not exceed $10^{-6}$.

Sample Input

3 3 2
1 2 1 0
2 3 1 0
1 3 1 1
3 3 2
1 2 1 0
2 3 1 0
1 3 0 5

Sample Output

1.75000000
2.00000000
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.