Description:
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).
Output
For 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 100Sample Output
Case 1: 12.9933758002 Case 2: 8.5431270393一个初始中奖率q=2,每次玩一局游戏,如果游戏赢了就抽奖,没抽到就q+2,然后继续玩游戏,如果游戏输了就q+1.5。问玩的游戏局数的期望,并且中奖率最高为100%
AC代码:
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdlib.h>
#include<queue>
#include<map>
#include<iomanip>
#include<math.h>
const int INF = 0x3f3f3f3f;
using namespace std;
typedef long long ll;
typedef double ld;
const int N=1e6+10;
const int MOD=998244353;
using namespace std;
int main()
{
int t,ca=1;
cin>>t;
while(t--)
{
double p;
scanf("%lf",&p);
p/=100;
double dp[240];
memset(dp,0,sizeof dp);
dp[200]=1/p;
for(int i=199; i >= 4; --i)
{
dp[i]=1+p*(1-1.0*i/200)*dp[min(i+4,200)];
dp[i]+=(1-p)*(dp[min(i+3,200)]);
}
printf("Case %d: %.10lf\n",ca++,dp[4]);
}
}