fzu 2278 YYS 数学
来源:互联网 发布:数据加密 ipguard 编辑:程序博客网 时间:2024/05/22 05:21
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.BufferedInputStream;import java.io.PrintWriter;import java.math.BigDecimal;import java.math.BigInteger;import java.util.Scanner;public class Main {public static void main(String[] args) {new Task().solve();}}class Task {Scanner in = new Scanner(new BufferedInputStream(System.in)) ;PrintWriter out = new PrintWriter(System.out);final int N = 3000 ;BigInteger[] F = new BigInteger[N+1] ;void solve(){F[0] = BigInteger.ONE ;for(int i = 1 ; i <= N ; i++){F[i] = F[i-1].multiply(BigInteger.valueOf(i)) ;}int t = in.nextInt() ;while(t-- > 0){int n = in.nextInt() ;BigInteger sum = BigInteger.ZERO ;for(int i = 1 ; i <= n ; i++){sum = sum.add( F[n].divide(BigInteger.valueOf(i))) ;}out.print(sum);out.println(".0") ;}out.flush() ;}}
- fzu 2278 YYS 数学
- 【期望】fzu 2278-- YYS
- FZU 2278 YYS
- YYS FZU
- 2017acm福建省赛FZU 2278 YYS
- fzu 2278 YYS [第八届福建省大学生程序设计竞赛 Problem G] [概率]
- FZU 1876 组合数学
- FZU 2147(数学,规律)
- FZU Number lengths(数学)
- FZU 2282 Wand 【组合数学】
- FZU 2125 简单的等式 (数学+枚举)
- FZU Problem 2146 Easy Game ( 数学啊)
- FZU Problem 2110 Star (数学啊 )
- FZU 2195 检查站点(数学啊)
- 平行四边形数 FZU 2231 计算数学
- FZU 2108 Mod problem 数学与模拟
- 【数学建模】FZU 1076 穿越沙漠
- FZU 2278 期望
- HDU
- 一劳永逸的搞定 flex 布局
- 被逼无奈自己修好了乐视电视!
- SQL的主键和外键的作用:
- 什么是I帧,P帧,B帧
- fzu 2278 YYS 数学
- Oracle初识笔记(一)
- 书籍截图
- 游戏产品的创新
- Python3基础-元组
- Android实现异步任务机制AsyncTask 的使用及源码分析
- android 自定义 View(4)- 进度条(ProgressBar)
- BST(线索二叉树实现)
- Servlet学习