传送门

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
 //import java.io.*;
import java.util.*;
import java.math.*; public class Main {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
BigInteger[] ans1 = new BigInteger[505];
BigInteger[] ans2 = new BigInteger[505];
BigInteger tmp;
ans1[1] = BigInteger.ONE;
ans2[1] = BigInteger.valueOf(2);
for(int i=2; i<=500 ;i++){
ans1[i]= ans1[i-1].multiply(BigInteger.valueOf(2*i-1));
ans2[i]= ans2[i-1].multiply(BigInteger.valueOf(2*i));
tmp=ans1[i].gcd(ans2[i]);
ans1[i] = ans1[i].divide(tmp);
ans2[i] = ans2[i].divide(tmp);
}
int t,n;
t=in.nextInt();
for(int i=1;i<=t;i++){
n = in.nextInt();
System.out.print(ans1[n]);
System.out.print('/');
System.out.println(ans2[n]);
}
}
}

hdu 4043 FXTZ II [ 概率 + Java大数]的更多相关文章

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

    FXTZ II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Su ...

  2. 【HDOJ】4043 FXTZ II

    1. 题目描述有n个球,第i个球的伤害值为$2^i-1, i \in [1,n]$.有甲乙两个人,每次由甲选择n个球中的一个,用它以相同概率攻击自己或者乙,同时彻底消耗这个球.这样的攻击最多进行n次. ...

  3. Buy the Ticket HDU 1133 卡特兰数应用+Java大数

    Problem Description The "Harry Potter and the Goblet of Fire" will be on show in the next ...

  4. hdu 1042 N! java大数及判断文件末尾

    N! Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submi ...

  5. 【百度之星】【java大数+C++做法】hdu 6719 Strassen

    代码:递归搜索一下.java大数做法 import java.util.*; import java.math.*; import java.security.MessageDigest; publi ...

  6. HDU4762(JAVA大数)

    Cut the Cake Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  7. 多校第五场 归并排序+暴力矩阵乘+模拟+java大数&amp;记忆化递归

    HDU 4911 Inversion 考点:归并排序 思路:这题呀比赛的时候忘了知道能够用归并排序算出逆序数,可是忘了归并排序的实质了.然后不会做-- 由于看到题上说是相邻的两个数才干交换的时候.感觉 ...

  8. HDU 3567 Eight II(八数码 II)

    HDU 3567 Eight II(八数码 II) /65536 K (Java/Others)   Problem Description - 题目描述 Eight-puzzle, which is ...

  9. Java 大数、高精度模板

    介绍: java中用于操作大数的类主要有两个,一个是BigInteger,代表大整数类用于对大整数进行操作,另一个是BigDecimal,代表高精度类,用于对比较大或精度比较高的浮点型数据进行操作.因 ...

随机推荐

  1. Apache CXF 框架结构和基本原理

    CXF旨在为服务创建必要的基础设施,它的整体架构主要由以下几个部分组成: 1.Bus 它是C X F架构的主干,为共享资源提供了一个可配置的场所,作用非常类似于S p r i n g的Applicat ...

  2. Android studio 时间选择器

    相当简单加载 gradle文件然后做一个textview即可. 1.首先我们要在build.gradle中写上这一行代码: compile 'com.feezu.liuli:timeselector: ...

  3. IF-MIB::ifTable = No Such Object available on this agent at this OID

    在server端口执行如下命令 [root@localhost ~]# snmpwalk -v2c -c public 客户端ip ifIF-MIB::ifTable = No Such Object ...

  4. SQL Server之增删改操作

    -------添加约束.增删改 use StudentDB2 go --------创建学生表--------- create table StudentInfo( --studentId int p ...

  5. Android从图库选择照片

    从机里取照片,开头用网上找的代码测试,导致类似下面这样的Crash:java.lang.RuntimeException: Failure delivering result java.lang.Se ...

  6. JavaEE-07 过滤器和监听器

    学习要点 过滤器 监听器 过滤器Filter 过滤器的概念 过滤器位于客户端和web应用程序之间,用于检查和修改两者之间流过的请求和响应. 在请求到达Servlet/JSP之前,过滤器截获请求. 在响 ...

  7. Java实现LRU(最近最少使用)缓存

    package com.jd.test; import java.io.Serializable; import java.util.LinkedHashMap; import java.util.c ...

  8. 模拟--P1328 生活大爆炸版石头剪刀布 题解

    P1328 生活大爆炸版石头剪刀布 这也是打表么?? #include <iostream> using namespace std; static const auto y = []() ...

  9. 3. 对系统表空间使用Raw磁盘分区

    3. 对系统表空间使用Raw磁盘分区 可以将raw磁盘分区用作InnoDB系统表空间中的数据文件.此技术可在Windows和某些Linux和Unix系统上启用非缓冲I/O,而无需文件系统开销.使用和不 ...

  10. Django框架基础知识05-自定义模板标签与过滤器

    根据一定规则,自己定义出符合需求功能的.用在任何你有需求的地方,因为内置的满足不了我们的需求,不同的东西有不同的定义规则 目前最最重要的就是HOW 一 文件路径配置: templates 存放自定义 ...