hdu 4043 FXTZ II [ 概率 ]

传送门

FXTZ II

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 530    Accepted Submission(s): 280

Problem Description

Cirno is playing a fighting game called "FXTZ" with Sanae.
Sanae is a ChuShou(master) of the game while Cirno is a ShaBao(noob). Since Cirno is a ShaBao, she just presses a random key on the keyboard for every 0.5 second, expecting to make a BiShaJi.
The battle begins. Having tried exactly 9 times, she finally makes a BiShaJi! She find herself summoned N iceballs!!! Then Sanae‘s HP decreases to 0 immediately....It should have been like that. But Cirno is too simple, always navie. She doesn‘t know how to handle the iceballs, so she starts to press the keyboard at random, again.
Let‘s see how the iceball damages. Each iceball has a fixed energy: the first ball‘s energy is 2^0, the second ball‘s energy is 2^1,..., and the N-th ball‘s energy is 2^(N-1). The damage caused by an iceball is equal to its energy. Cirno will shoot N times. Since Cirno is pressing the keyboard at random, each time Cirno will choose exactly one iceball with equal possibility to shoot out. Once shot out, the iceball can‘t be chosen again. And even worse, the target may be either her opponent or herself, with equal possibility(50%). What a big ShaBao she is. =_=
During shooting, once Cirno‘s HP is less than Sanae‘s, she will lose the game. Otherwise, she wins.
You may assume Sanae did nothing while Cirno‘s shooting(all damages are caused by Cirno‘s iceball), and their original HP are both 2^N (No one will die in the middle of the battle unless Cirno‘s HP is less than Sanae‘s).
Here comes the question: Can you calculate the possibility of Cirno‘s victory?

Input

The first line an integer C (C<=30), the number of test cases.
For each case, the only line contains one integer N(0<N<=500), indicating the number of iceballs.

Output

For each case output a fraction, the possibility of Cirno‘s victory. The fraction must be reduced.

Sample Input

2
1
4

Sample Output

1/2
35/128

Source

The 36th ACM/ICPC Asia Regional Beijing Site —— Online Contest

Recommend

lcy   |   We have carefully selected several similar problems for you:  4050 4044 4047 4042 4048

第一个java大数~\(≧▽≦)/~啦啦啦

题解就转一下啦: http://blog.csdn.net/julyana_lin/article/details/7885083

13108490 2015-03-13 10:22:15 Accepted 4043 312MS 9460K 775 B Java czy
 1 //import java.io.*;
 2 import java.util.*;
 3 import java.math.*;
 4
 5 public class Main {
 6     public static void main(String[] args){
 7         Scanner in = new Scanner(System.in);
 8         BigInteger[] ans1 = new BigInteger[505];
 9         BigInteger[] ans2 = new BigInteger[505];
10         BigInteger tmp;
11         ans1[1] = BigInteger.ONE;
12         ans2[1] = BigInteger.valueOf(2);
13         for(int i=2; i<=500 ;i++){
14             ans1[i]= ans1[i-1].multiply(BigInteger.valueOf(2*i-1));
15             ans2[i]= ans2[i-1].multiply(BigInteger.valueOf(2*i));
16             tmp=ans1[i].gcd(ans2[i]);
17             ans1[i] = ans1[i].divide(tmp);
18             ans2[i] = ans2[i].divide(tmp);
19         }
20         int t,n;
21         t=in.nextInt();
22         for(int i=1;i<=t;i++){
23             n = in.nextInt();
24             System.out.print(ans1[n]);
25             System.out.print(‘/‘);
26             System.out.println(ans2[n]);
27         }
28     }
29 }
时间: 2024-08-16 13:51:36

hdu 4043 FXTZ II [ 概率 ]的相关文章

HDU 4043 FXTZ II (组合数学-排列组合)

FXTZ II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 498    Accepted Submission(s): 266 Problem Description Cirno is playing a fighting game called "FXTZ" with Sanae. Sanae is a ChuShou

HDU 4043 Eliminate Witches! (求概率推公式 + 大数)

FXTZ II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 525    Accepted Submission(s): 276 Problem Description Cirno is playing a fighting game called "FXTZ" with Sanae. Sanae is a ChuShou

HDU 4870 Rating(概率、期望、推公式) &amp;&amp; ZOJ 3415 Zhou Yu

其实zoj 3415不是应该叫Yu Zhou吗...碰到ZOJ 3415之后用了第二个参考网址的方法去求通项,然后这次碰到4870不会搞.参考了chanme的,然后重新把周瑜跟排名都反复推导(不是推倒)四五次才上来写这份有抄袭嫌疑的题解... 这2题很类似,多校的rating相当于强化版,不过原理都一样.好像是可以用高斯消元做,但我不会.默默推公式了. 公式推导参考http://www.cnblogs.com/chanme/p/3861766.html#2993306 http://www.cn

HDU 3567 Eight II(八数码 II)

p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-size: 10.5000pt } h1 { margin-top: 5.0000pt; margin-bottom: 5.0000pt; text-align: center; font-family: 宋体; color: rgb(26,92,200); font-weight: bold; fo

hdu 5147 Sequence II(树状数组)

题目链接:hdu 5147 Sequence II 预处理每个位置作为b和c可以组成的对数,然后枚举b的位置计算. #include <cstdio> #include <cstring> #include <algorithm> using namespace std; typedef long long ll; const int maxn = 50005; int N, arr[maxn], fenw[maxn], lef[maxn], rig[maxn]; #d

HDU 4652 Dice (概率DP)

Dice Problem Description You have a dice with m faces, each face contains a distinct number. We assume when we tossing the dice, each face will occur randomly and uniformly. Now you have T query to answer, each query has one of the following form: 0

HDU 3366 Passage (概率DP)

Passage Problem Description Bill is a millionaire. But unfortunately he was trapped in a castle. There are only n passages to go out. For any passage i (1<=i<=n), Pi (0<=Pi<=1) denotes the probability that Bill will escape from this castle saf

HDU 3081Marriage Match II(二分+并查集+网络流之最大流)

题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=3081 有一段时间没写最大流的题了,这题建图居然想了好长时间...刚开始是按着最终的最大流即是做多轮数去想建图,结果根本没思路,后来想了想,可以用二分答案的思想来找最终答案.然后很明显的并查集,但是并查集学的略渣,居然卡在并查集上了..= =. 但是也不是并查集的事..是我建图的思想太正了,稍微用点逆向思维并查集就可以很好利用了. 建图思路是:建立一个源点与汇点,将女孩与源点相连,男孩与汇点相连,权值

[ACM] HDU 4576 Robot (概率DP,滚动数组)

Robot Problem Description Michael has a telecontrol robot. One day he put the robot on a loop with n cells. The cells are numbered from 1 to n clockwise. At first the robot is in cell 1. Then Michael uses a remote control to send m commands to the ro