码迷,mamicode.com
首页 > 其他好文 > 详细

hdu 4043 FXTZ II [ 概率 ]

时间:2015-03-13 10:48:00      阅读:254      评论:0      收藏:0      [点我收藏+]

标签:

传送门

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
 

 

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 }

 

hdu 4043 FXTZ II [ 概率 ]

标签:

原文地址:http://www.cnblogs.com/njczy2010/p/4334443.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!