zoukankan      html  css  js  c++  java
  • Scout YYF I

    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
  • 相关阅读:
    机器学习概要
    Latex公式压缩
    MATLAB多项式运算
    利用MathType为公式编号并引用
    MATLAB符号对象与符号运算
    MATLAB矩阵运算
    MATLAB绘制函数图
    MATLAB程序控制语句
    MATLAB关系运算符和逻辑运算符
    Raspberry pi之wifi设置-3
  • 原文地址:https://www.cnblogs.com/dealer/p/13175377.html
Copyright © 2011-2022 走看看