Занятие 1 |

Занятие 2 |

Занятие 3 |

Занятие 4 |

Занятие 5 |

Занятие 6 |

Занятие 7 |

Занятие 8 |

Занятие 9 |

Занятие 10 |

Занятие 11 |

Занятие 12 |

Занятие 14 |

Занятие 15 |

Занятие 16 |

Занятие 17 |

Занятие 18 |

Занятие 19 |

Занятие 20 |

03/06/2023 13:57:18

A. ASCII Art B. Billing Tables C. Cellular Automaton D. Driving Directions E. Exchange F. Fool's Game G. Graveyard H. Hard Life I. Interconnect J. Java vs C++ K. Kickdown

Теория вероятностей

Генерация всех подмножеств, сочетаний, перестановок

Олимпиадные задачи на английском языке

Генерация всех подмножеств, сочетаний, перестановок

Олимпиадные задачи на английском языке

12/12/2006 | Практическое занятие 13 (задачи NEERC 2006) (I) |

*Ограничения: время – 3s/6s, память – 64MiB Ввод: input.txt или стандартный ввод Вывод: output.txt или стандартный вывод*

Послать решение Blockly Посылки Темы Где Обсудить (0)

There are two serious problems in the Kingdom of Lipshire: the roads and the fools who build them.
Once upon a time, the King of Lipshire has decided to improve the road system because some roads
became completely impassable — it was easier to travel cross-country instead of using those roads.

By King’s decree, new roads are to be built in Lipshire. Of course, the new road system must interconnect
all towns, i. e. there must be a path connecting any two towns of Lipshire.

The road administration of Lipshire has resources to build exactly one road per year. Unfortunately, the
fools who build these roads are completely out of control. So, regardless of the orders given, the fools
randomly select two different towns `a` and `b` and build a road between them, even when those towns are
already connected by a road. All possible choices are equiprobable. The road is build in such a manner
that the only points where a traveler can leave it are the towns connected by this road. The only good
thing is that all roads are bidirectional.

The King knows about the problem, but he cannot do anything about it. The only thing King needs to
know is the expected number of years to wait before the road system of Lipshire becomes interconnected.
He asked you to provide this information.

The first line of the input contains two integers `n` and `m\ (2\ ≤\ n\ ≤\ 30,\ 0\ ≤\ m\ ≤\ 1\ 000)` — the number of
towns in Lipshire, and the number of roads which are still good. The following `m` lines describe roads,
one per line. Each road is described with two endpoints — two integer numbers `u_i` and `v_i\ (1\ ≤\ u_i;\ v_i\ ≤\ n,\ u_i\ ≠\ v_i)`. There can be multiple roads between two towns, but the road from a town to itself is not
allowed.

Output the expected number of years to wait for the interconnected road system. If the system is already
interconnected, output zero as an answer. Output the number with at least six precise digits after the
decimal point.

Sample Input #1

2 1 1 2

Sample Output #1

0.0

Sample Input #2

4 2 1 2 3 4

Sample Output #2

1.5