FZU - 2278 YYS(期望)

本文探讨了在著名手机RPG游戏《阴阳师》中收集不同卡片所需的期望天数。通过数学方法求解每次抽取新卡所需的时间,并考虑到了每种卡出现的概率相同的情况。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Yinyangshi is a famous RPG game on mobile phones.

Kim enjoys collecting cards in this game. Suppose there are n kinds of cards. If you want to get a new card, you need to pay W coins to draw a card. Each time you can only draw one card, all the cards appear randomly with same probability 1/n. Kim can get 1 coin each day. Suppose Kim has 0 coin and no cards on day 0. Every W days, Kim can draw a card with W coins. In this problem ,we define W=(n-1)!.

Now Kim wants to know the expected days he can collect all the n kinds of cards.

Input

The first line an integer T(1 ≤ T ≤ 10). There are T test cases.

The next T lines, each line an integer n. (1≤n≤3000)

Output

For each n, output the expected days to collect all the n kinds of cards, rounded to one decimal place.

Sample Input
4
1
2
5
9
Sample Output
1.0
3.0
274.0
1026576.0


题意:抽n张不同的牌,每一次只能抽一张牌,抽到每张牌的概率都是相等的,都是1/n。每隔W天抽一次,W=(n-1)!。问预期多少天能抽完。


解题思路:

老铁kangzzz求期望真的是无敌666了


求出期望的次数然后乘上W即为结果。


在解题上有个难点就是怎么求期望,在求出公式后的难点就是怎么求W,W是一个3000的阶乘,用java可以实现,C语言先放放。。


举例:

n==2时,

抽第一张不同的牌只需要1次

抽第二张不同的牌的概率是1/2,预期的次数是1/(1/2)=2 次

所以总的预期天数是(1+2)*W==3天


n==3时,

抽第一张不同的牌只需要1次,

抽剩余两张不同的牌的概率是2/3,那么预期的次数就是1/(2/3)==3次,平均抽每张牌就需要3/2次

再抽剩余的一张牌需要的次数就是3/1次


所以公式就是(n/n+n/(n-1)+n/(n/2)+...+n/1)*(n-1)!



评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值