hdu 4043 FXTZ II [ 概率 + Java大数]
FXTZ II
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 530 Accepted Submission(s): 280
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?
For each case, the only line contains one integer N(0<N<=500), indicating the number of iceballs.
1
4
35/128
第一个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大数]的更多相关文章
- HDU 4043 FXTZ II (组合数学-排列组合)
FXTZ II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Su ...
- 【HDOJ】4043 FXTZ II
1. 题目描述有n个球,第i个球的伤害值为$2^i-1, i \in [1,n]$.有甲乙两个人,每次由甲选择n个球中的一个,用它以相同概率攻击自己或者乙,同时彻底消耗这个球.这样的攻击最多进行n次. ...
- Buy the Ticket HDU 1133 卡特兰数应用+Java大数
Problem Description The "Harry Potter and the Goblet of Fire" will be on show in the next ...
- hdu 1042 N! java大数及判断文件末尾
N! Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submi ...
- 【百度之星】【java大数+C++做法】hdu 6719 Strassen
代码:递归搜索一下.java大数做法 import java.util.*; import java.math.*; import java.security.MessageDigest; publi ...
- HDU4762(JAVA大数)
Cut the Cake Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tota ...
- 多校第五场 归并排序+暴力矩阵乘+模拟+java大数&记忆化递归
HDU 4911 Inversion 考点:归并排序 思路:这题呀比赛的时候忘了知道能够用归并排序算出逆序数,可是忘了归并排序的实质了.然后不会做-- 由于看到题上说是相邻的两个数才干交换的时候.感觉 ...
- HDU 3567 Eight II(八数码 II)
HDU 3567 Eight II(八数码 II) /65536 K (Java/Others) Problem Description - 题目描述 Eight-puzzle, which is ...
- Java 大数、高精度模板
介绍: java中用于操作大数的类主要有两个,一个是BigInteger,代表大整数类用于对大整数进行操作,另一个是BigDecimal,代表高精度类,用于对比较大或精度比较高的浮点型数据进行操作.因 ...
随机推荐
- Makefile介绍
make 工具如 GNU make.System V make 和 Berkeley make 是用来组织应用程序编译过程的基本工具,但是每个 make 工具之间又有所不同.不同的make工具的mak ...
- 不能说的hidden
不能说的hidden 时光跑跑...路在脚下...晨光依在...----Vashon 1.所谓"时尚",本质上就是自己看不见自己的样子.好比我们在地球上,却感觉不到地球在动. 2. ...
- System.currentTimeMillis()与日期之间的相互转换
System.currentTimeMillis()与日期 之间是可以相互转换的,大多数Android开发者都知道 通过 SimpleDateFormat dateformat = new Simpl ...
- CocosCreator工程内的命名
命名结构总体的命名结构遵循以下格式 前缀-内容-尾缀 - 前缀:用来定义node的属性- 内容:node的名字- 尾缀:序列或状态1231. 前缀说明:在开始的时候定义/声明这个节点的属性前缀可以是一 ...
- zipkin 服务追踪
服务追踪,就是对请求接口的追踪并保存. 在测试的过程中我们会发现,有时候,程序刚刚启动后,刷新几次,并不能看到任何数据,原因就是我们的spring-cloud-sleuth收集信息是有一定的比率的,默 ...
- 1+1/2+1/3+...+1/n为素数的证明
我们考虑不大于 n的最大的2 的幂 2^k. 令 有 其中 a/b是剩下的所有的项的和,由于乘以了最大的 2的幂,所以剩下的所有项的分母都是奇数,故而 b是奇数.如果 m是整数,那么就会导致等式右边的 ...
- react中的jsx详细理解
这是官网上的一个简单的例子 const name = 'Josh Perez'; const element = <h1>Hello, {name}</h1>; ReactDO ...
- 创建线程的三种方式_Callable和Runnable的区别
Java 提供了三种创建线程的方法 通过实现Runnable接口 通过继承Thread接口 通过Callable和Future创建线程 通过实现 Runnable 接口来创建线程 public cla ...
- Microsoft Windows Server DHCP
Microsoft Windows Server DHCP DHCP IP地址第一个来源是DHCP服务器,第二个来源是PPP点对点协议(ADSL为PPPOE);DHCP是Dynamic Host Co ...
- VR技术在数据中心3D机房中的应用(上)
VR技术在数据中心3D机房中的应用(上) 前两天跟朋友A吃饭,吃着吃着就说到了VR.近几年来,VR技术越来越火,感觉能跟VR沾点边的都特别高大上,朋友A也是,一提到VR,就怎么都掩盖不住他发自肺腑 ...