【POJ 3557】Map Generator
来源:互联网 发布:导入mac的照片存在哪里 编辑:程序博客网 时间:2024/04/29 22:21
Map Generator
Time Limit: 5000MS Memory Limit: 65536K
Total Submissions: 1319 Accepted: 361
Case Time Limit: 2000MS Special Judge
Description
The scene of the new computer game “Battles in Space: Unification” (BSU) is laid in far future. Mankind is scattered on N planets hostile to each other. A player of the game is a leader of one the planets. Using diplomatic tricks and military the player needs to occupy the rest of the planets and, doing so, reunite mankind.
Special hyperspace tunnels are used to travel from one planet to another. Each tunnel connects two of the planets and can be used for communication in both directions. Two planets can not be connected by more then one tunnel. The set of all tunnels connecting the planets is called the map of the game.
Currently, developers of BSU are working on generator of maps of the game. It has been decided to use the special algorithm called «Fine Artificial Model of Intelligence» (FAMI) for this purpose. The algorithm operates in the following way. For each pair of planets i and j (1 ≤ i < j ≤ N) a random real number Xij (0 ≤ Xij ≤ 1) is generated. Uniform distribution is used to generate random numbers and numbers Xij are generated independently. Next, if Xij ≤ P, where parameter P is a real number, then the hyperspace tunnel connecting planets i and j is added into the map being generated.
Developers wish the map generator produced connected maps. A map is said to be connected when between any pair of planets there is a path, consisting of one or more hyperspace tunnels. Unfortunately, it appears that maps generated by FAMI algorithm sometimes are not connected. You are assigned to research this phenomenon.
You need to write a program which being given numbers N and P calculates probability of generating connected map by FAMI algorithm.
Input
The input consists of two lines. The first line contains an integer number N (1 ≤ N ≤ 20), while the second line contains a real number P (0 ≤ P ≤ 1).
Output
The output needs to contain an answer – the single real number which is the probability of generating connected map by FAMI algorithm. Absolute error of the answer must not exceed 10−2.
Sample Input
3
0.5
Sample Output
0.5
Source
Northeastern Europe 2005, Western Subregion
题意就是给定两个数n,p;表示n个点中任意两点连边的概率为p,求生成的图是个连通块的概率
╮(╯▽╰)╭我先存个题题解回来补……
- 【POJ 3557】Map Generator
- poj 3557 Map Generator 概率
- POJ 1597 Uniform Generator
- poj 1597 Uniform Generator
- poj 1597 Uniform Generator
- POJ 1597 Uniform Generator 模拟
- 【POJ 1597】【数论】 Uniform Generator
- POJ 1597 Uniform Generator 笔记
- myBatis Generator配置及DAO/Map生成
- Generator
- generator
- Generator
- generator
- Generator
- generator
- Generator
- Generator
- generator
- JAVA之类的无参方法
- Android标签页TabLayout控件实战及ViewPager取消预加载
- 我的人生路2016
- 在CUDA C/C++中如何隐藏数据传输
- 客户端与服务器
- 【POJ 3557】Map Generator
- LeetCode 141. Linked List Cycle
- 关于<< EOF EOF; 是什么意思?
- IAR调试时出现“PC of target system has uxexpected value after checking target RAM”
- Fatal error: Cannot override final method Mage_Core_Model_Abstract::clearInstance()
- POJ 1845 Sumdiv (数论,约数和)
- 一维数组常见的三种排序、冒泡排序、选择排序、插入排序、Arrays内置排序
- C++——字符串例题——487-3279(POJ1002)
- 一个完整的壁纸应用——[仿爱壁纸],从设计到实现的过程