PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#FW0000007. Chuyển trang (Page Hopping)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Chuyển trang (Page Hopping)
Page Hopping
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
Directed links connect web pages. For every ordered pair of distinct pages with a route, consider the minimum clicks. Compute the mean over reachable ordered pairs.
Input
followed by directed links .
Output
Print the average with exactly three digits after the decimal point.
Subtasks
- Subtask 1 (40 points): at most distinct pages; ; ; .
- Subtask 2 (60 points): ; ; .
Examples
Input
3
1 2
2 3
3 1
Output
1.500
Explanation
Three ordered pairs require one click and three require two clicks. The mean is .