当前位置:网站首页>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+矩阵快速幂而已..
边栏推荐
- MySQL的索引和事务
- Tsinghua | GLM-130B: An Open Bilingual Pre-training Model
- (6) FlinkSQL writes kafka data to mysql Method 1
- 程序员必备的VS调试技巧
- 2020年是时候更新你的技术武器库了:Asgi vs Wsgi(FastAPI vs Flask)
- KD-SCFNet:通过知识蒸馏实现更准确、更高效的显着目标检测(ECCV2022)
- 如果Controller里有私有的方法,能成功访问吗?
- C language small project - complete code of minesweeper game (recursive expansion + selection mark)
- 【Redis】redis安装与客户端redis-cli的使用(批量操作)
- 行业领先的界面开发组件DevExpress 8月发布新版——v22.1.4
猜你喜欢
随机推荐
6. [opencv mouse callback event]
Thesis understanding: "Self-adaptive loss balanced Physics-informed neural networks"
一名合格的程序员是如何优雅地解决线上问题的?
The programmer essential VS debugging technique
【C语言】深度剖析数据在内存中的存储
【Redis】redis安装与客户端redis-cli的使用(批量操作)
R语言使用位置索引筛选dataframe的数据列:筛选单个数据列、筛选多个数据列、列表表达式方法、矩阵式下标方法
(6)FlinkSQL将kafka数据写入到mysql方式一
MapStruct入门使用
连锁小酒馆第一股,海伦司能否梦圆大排档?
Docker-持久化数据库(数据卷)
如果Controller里有私有的方法,能成功访问吗?
干货满满,中科院信工所于静新课帮你get学术研究与论文写作技能
The use of string function, character function, memory function and its analog implementation
textarea disable drag and drop
(8)FlinkSQL自定义UDF
【软考 系统架构设计师】软件架构设计⑥ 软件产品线
KD-SCFNet: More Accurate and Efficient Salient Object Detection Through Knowledge Distillation (ECCV2022)
第十二届蓝桥杯《杨辉三角》-二分法
Docker - persistent database (data volume)