传送门

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. Java&Xml教程(十)XML作为属性文件使用

    我们通常会将Java应用的配置参数保存在属性文件中,Java应用的属性文件可以是一个正常的基于key-value对,以properties为扩展名的文件,也可以是XML文件. 在本案例中,將会向大家介 ...

  2. Oracle体系结构总览

    第一篇 Oracle架构总览 先让我们来看一张图   这张就是Oracle 9i的架构全图.看上去,很繁杂.是的,是这样的.现在让我们来梳理一下: 一.数据库.表空间.数据文件 1.数据库 数据库是数 ...

  3. react基础语法(五) state和props区别和使用

    props的验证: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> < ...

  4. 接口自动化- 基于 Python

    准备工作 这部分其实在谷歌或者百度上搜索下就可以完成的,可是我就是想再啰嗦一遍,说不定有比我更懒的同学呢哈哈~ 第一步 Python的安装配置 打开官网: https://www.python.org ...

  5. 洛谷 P1030 求先序排列

    题目描述 给出一棵二叉树的中序与后序排列.求出它的先序排列.(约定树结点用不同的大写字母表示,长度<=8). 输入输出格式 输入格式: 2行,均为大写字母组成的字符串,表示一棵二叉树的中序与后序 ...

  6. MySQL数据表查询操作

    准语法结构:编写DQL时一定要严格按照此语法的顺序来实现!/* SELECT [ALL | DISTINCT] ALL表示查询出所有的内容 DISTINCT 去重 {* | 表名.* | 表名.字段名 ...

  7. Java后端学习路线_备战

    SpringCloud项目实战 Dubbo项目实战 项目实战应涵括哪些技术: 缓存.消息队列 WEB应用服务器(Weblogic.Jetty.JBoss.WebSphere) NoSQL(MongoD ...

  8. dnsquery - 使用解析程序查询域名服务器

    SYNOPSIS(总览) dnsquery [-n nameserver ] [-t type ] [-c class ] [-r retry ] [-p period ] [-d ] [-s ] [ ...

  9. android 解密工具

    androguard. 这个是python写的 安装: pip install androguard

  10. linux 隐藏进程

    1.首先推荐一个后门程序https://github.com/f0rb1dd3n/Reptile 具体可以了解一下功能非常强大. 2.源码如下 root@ubuntu:/var/srt/libproc ...