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,代表高精度类,用于对比较大或精度比较高的浮点型数据进行操作.因 ...
随机推荐
- TCAM 与CAM
CAM是Content Addressable Memory的缩写,即"内容寻址存储器"的意思,它是在传统的存储技术的基础上实现的联想记忆存储器,关于CAM的基本操作有三种: 1) ...
- 北京区域赛I题,Uva7676,A Boring Problem,前缀和差分
转载自https://blog.csdn.net/weixin_37517391/article/details/83821752 题解 其实这题不难,只要想到了前缀和差分就基本OK了. 我们要求的是 ...
- END - 提交当前的事务
SYNOPSIS END [ WORK | TRANSACTION ] DESCRIPTION 描述 END END 提交当前事务. 所有当前事务做的修改都可被其它事务看到并且保证在发生崩溃的情况下的 ...
- ssget使用方法
语法: (ssget [sel-method] [pt1 [pt2]] [pt-list] [filter-list]) ssget 的参数均为可选参数,需要注意的是可选参数之间的组合条件.以下语法表 ...
- c++:delete或free报错,语法正常。
#include <stdio.h> #include <iostream> int _tmain(int argc, _TCHAR* argv[]) { ]; memcpy( ...
- 1.ssm web项目中的遇到的坑--自定义JQuery插件(slide menu)
自定义的JQuery插件写的回调函数不执行: 写好了回调函数,将函数打印出来是原形,就是不执行 function () { console.log("---onClickItem---&qu ...
- spring注解开发-扩展原理(源码)
1.BeanFactoryPostProcessor BeanPostProcessor:bean后置处理器,bean创建对象初始化前后进行拦截工作的; BeanFactoryPostProcesso ...
- 关于python字符串拼接的几种方法
当时看完python的基本语法后 给朋友写了个美元概率换算 写完后拼接结果时候 发现压根不知道python怎么拼接字符串 看了些资料自己做了个总结 首先就是和JavaScript一样的拼接方式 nam ...
- 2. CHARACTER_SETS
2. CHARACTER_SETS CHARACTER_SETS表提供有关可用字符集的信息. 下表中的SHOW Name值对应于SHOW CHARACTER SET语句的列名. INFORMATION ...
- 【JavaEE-面试总结】(未完,待续···)
目录: 一.Java基础 二.JavaEE基础 三.JavaEE进阶 四.数据库 五.数据结构&算法 六.高级(服务器) 一.Java基础 1.1 面向对象(封装.继承.多态) 访问权限修饰符 ...