当前位置:网站首页>poj3744 Scout YYF I
poj3744 Scout YYF I
2022-08-08 13:21:00 【51CTO】
http://www.elijahqi.win/archives/3628
Description
YYF is a couragous scout. Now he is on a dangerous mission which is to penetrate into the enemy’s base. After overcoming a series difficulties, YYF is now at the start of enemy’s famous “mine road”. This is a very long road, on which there are numbers of mines. At first, YYF is at step one. For each step after that, YYF will walk one step with a probability of p, or jump two step with a probality of 1-p. Here is the task, given the place of each mine, please calculate the probality that YYF can go through the “mine road” safely.
Input
The input contains many test cases ended with EOF.
Each test case contains two lines.
The First line of each test case is N (1 ≤ N ≤ 10) and p (0.25 ≤ p ≤ 0.75) seperated by a single blank, standing for the number of mines and the probability to walk one step.
The Second line of each test case is N integer standing for the place of N mines. Each integer is in the range of [1, 100000000].
Output
For each test case, output the probabilty in a single line with the precision to 7 digits after the decimal point.
Sample Input
1 0.5
2
2 0.5
2 4
Sample Output
0.5000000
0.2500000
Source
POJ Monthly Contest - 2009.08.23, Simon
注意tle可能因为在快速幂的时候出现连续两个雷在一起的情况 特判之即可
剩下就是普通dp+矩阵快速幂而已..
边栏推荐
- PHP中使用XML-RPC构造Web Service简单入门
- C language small project -- address book (static version + dynamic version + file version)
- STM32入门开发 制作红外线遥控器(智能居家-万能遥控器)
- 2022-08-05
- 医药行业转型发展,探索数字化供应链升级之道
- textarea disable drag and drop
- 自动当道,效率至上 | 快来解锁财务共享服务中心数字化秘籍
- (5)FlinkSQL将socket数据写入到mysql方式二
- 一桩事先张扬的网红书店倒闭案
- 使用单点登录 (SSO):便捷访问,降低风险,精简流程
猜你喜欢
随机推荐
一名合格的程序员是如何优雅地解决线上问题的?
一文搞懂│XSS攻击、SQL注入、CSRF攻击、DDOS攻击、DNS劫持
Program Environment and Preprocessing
OFD是什么
腾讯,投了个 “离诺贝尔奖最近的华人”
serialize 序列化原生方法
医药行业转型发展,探索数字化供应链升级之道
KD-SCFNet:通过知识蒸馏实现更准确、更高效的显着目标检测(ECCV2022)
changes not staged for commit solution
(7)FlinkSQL将kafka数据写入到mysql方式二
自动当道,效率至上 | 快来解锁财务共享服务中心数字化秘籍
【软考 系统架构设计师】软件架构设计⑦ 构件与中间件技术
In-depth analysis of the soul of C language -- pointer
R语言ggplot2可视化:使用ggpubr包的ggline函数可视化折线图(点线图、line plot)、设置add参数为mean可视化不同水平均值的折线图
将小部分源码设计精髓带入到开发中来(工厂模式、适配器模式、抽象类、监听器)
STM32入门开发 制作红外线遥控器(智能居家-万能遥控器)
Fluorite, millet against smart camera
(5) FlinkSQL writes socket data to mysql Method 2
哈佛大学砸场子:DALL-E 2只是「粘合怪」,生成正确率只有22%
专访|360高瀚昭:ISC十年,360数字安全大脑能够“看见”什么?