【期望】fzu 2278-- YYS
来源:互联网 发布:网络机顶盒多少钱一个 编辑:程序博客网 时间:2024/06/06 10:48
Accept: 39 Submit: 118
Time Limit: 1000 mSec Memory Limit : 262144 KB
Problem Description
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
Sample Output
Source
第八届福建省大学生程序设计竞赛-重现赛(感谢承办方厦门理工学院)import java.io.*;import java.math.BigInteger;import java.util.*;public class Main {public static void main(String[] args){Scanner in=new Scanner(System.in);BigInteger a[]=new BigInteger[3500];a[0]=new BigInteger("1");for(int i=1;i<=3100;i++){ BigInteger t=BigInteger.valueOf(i);a[i]=a[i-1].multiply(t);}int test=in.nextInt();while(test-->0){int n=in.nextInt();BigInteger sum=BigInteger.ZERO;for(int i=1;i<=n;i++)sum=sum.add(a[n].divide(BigInteger.valueOf(i)));System.out.print(sum);System.out.println(".0");}}}
- 【期望】fzu 2278-- YYS
- fzu 2278 YYS 数学
- FZU 2278 YYS
- YYS FZU
- 2017acm福建省赛FZU 2278 YYS
- FZU 2278 期望
- fzu 2278 YYS [第八届福建省大学生程序设计竞赛 Problem G] [概率]
- 第八届福建省大学生程序设计竞赛 G.YYS【期望+大数】
- FZU
- FZU
- FZU
- FZU
- FZU
- FZU
- FZU
- FZU
- FZU
- FZU
- C/C++程序编译流程解析(预处理->编译->汇编->链接)
- CentOS7安装iptables防火墙
- JS中的函数声明提升和变量声明提升
- 字符集编码 Unicode UTF8 UTF16 UTF32 和BOM(Byte Order Mark)
- 查询数据库中指定字段符合条件的记录数
- 【期望】fzu 2278-- YYS
- PAT B1034. 有理数四则运算
- Slave_SQL_Running: No的解决办法
- SQLSERVER2008 (T-SQL汇总二)
- copy构造函数调用情况
- 关于极光推送,部分手机收不到的分析
- iOS设置主题颜色方便使用
- Qt按键 (自定义样式)
- 本地图片转base64格式上传到服务器(php)