加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

2018CCPC吉林赛区 D - The Moon

发布时间:2020-12-14 05:58:06 所属栏目:Windows 来源:网络整理
导读:Time limit1000 ms Memory limit262144 kB Special judgeYes OSWindows The Moon card shows a large,full moon in the night’s sky,positioned between two large towers. The Moon is a symbol of intuition,dreams,and the unconscious. The light of th
Time limit1000 ms Memory limit262144 kB Special judgeYes OSWindows
The Moon card shows a large,full moon in the night’s sky,positioned between two large towers. The Moon is a symbol of intuition,dreams,and the unconscious. The light of the moon is dim,compared to the sun,and only vaguely illuminates the path to higher consciousness which winds between the two towers.

Random Six is a FPS game made by VBI(Various Bug Institution). There is a gift named "Beta Pack". Mr. K wants to get a beta pack. Here is the rule.
Step 0. Let initial chance rate? qq?= 2%.
Step 1. Player plays a round of the game with winning rate?pp.
Step 2. If the player wins,then will go to Step 3 else go to Step 4.
Step 3. Player gets a beta pack with probability?qq. If he doesn’t get it,let?qq?= min(100%,?qq?+ 2%) and he will go to Step 1.
Step 4. Let?qq?= min(100%,?qq?+ 1.5%) and goto Step 1.
Mr. K has winning rate?pp%,he wants to know what’s the expected number of rounds before he needs to play.

Input

The first line contains testcase number?TT?(TT?≤ 100). For each testcase the first line contains an integer?pp?(1 ≤?pp?≤ 100).OutputFor each testcase print?Case?ii?: and then print the answer in one line,with absolute or relative error not exceeding?106106.

Sample Input

2
50
100

Sample Output

Case 1: 12.9933758002
Case 2: 8.5431270393

概率dp题,从100开始逆推,状态转移方程为dp[i]=p*((i/1000.0)+(1-i/1000.0)*(1+dp[min(i+20,1000)]))+(1-p)*(1+dp[min(1000,i+15)]);
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    scanf("%d",&t);
    for(int l=1;l<=t;++l)
    {
        double p;
        scanf("%lf",&p);
        double dp[1005];
        p/=100;
        dp[1000]=1/p;
        for(int i=999;i>=20;--i)
        {
            dp[i]=p*((i/1000.0)+(1-i/1000.0)*(1+dp[min(i+20,1000)]));
            dp[i]+=(1-p)*(1+dp[min(1000,i+15)]);
        }
        printf("Case %d: %.10fn",l,dp[20]);
    }
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读