微软2017年预科生计划在线编程笔试 题目1 : Legendary Items

题目1 : Legendary Items

所有题目在此:https://hihocoder.com/contest/mstest2017march/problems

答案:https://github.com/hiho-coder/msft-2017-online-test-solution/blob/master/README.md

这道题关键在于数学期望值的计算。如果使用题目给定的公式:

2*50%*25% + 3*50%*75%*100% + 3*50%*100%*25% + 4*50%*100%*75%*100% = 3.25

那么在计算的时候还要算上走过的路径。但实际上,由于每件物体获得的概率都是独立的:P(n) = P(n-1)/2^(n-1)

所以数学期望值可以分开计算。

第一件物体的期望值:0.5*1+0.5*1.0*2=1.5

第二件物体的期望值:0.25*1+0.75*1*2=1.75

1.5+1.75=3.25,与上面的计算方法得到的结果相同。 但如果使用上面的方法进行计算,则过程会复杂很多。 

 

时间限制:10000ms

单点时限:1000ms

内存限制:256MB

描述

Little Hi is playing a video game. Each time he accomplishes a quest in the game, Little Hi has a chance to get a legendary item.

At the beginning the probability is P%. Each time Little Hi accomplishes a quest without getting a legendary item, the probability will go up Q%. Since the probability is getting higher he will get a legendary item eventually.

After getting a legendary item the probability will be reset to ⌊P/(2I)⌋% (⌊x⌋ represents the largest integer no more than x) where I is the number of legendary items he already has. The probability will also go up Q% each time Little Hi accomplishes a quest until he gets another legendary item.

Now Little Hi wants to know the expected number of quests he has to accomplish to get N legendary items.  

Assume P = 50, Q = 75 and N = 2, as the below figure shows the expected number of quests is

2*50%*25% + 3*50%*75%*100% + 3*50%*100%*25% + 4*50%*100%*75%*100% = 3.25

输入

The first line contains three integers P, Q and N.  

1 ≤ N ≤ 106, 0 ≤ P ≤ 100, 1 ≤ Q ≤ 100

输出

Output the expected number of quests rounded to 2 decimal places.

样例输入

50 75 2

样例输出

3.25
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值