FXTZ II
Accept:15     Submit:28
Time Limit:1000MS     Memory Limit:65536KB
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 naïve. 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

分母很好算:

n!*2^n

意思是全排列乘以2^n个状态

然后分子的公式很难推。我是用DFS打表看出来的规律

规律为:1*3*5*7*...*(2*n-1)

于是可以直接用java水过:

我的代码:

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

HDU/HDOJ 4043 BUPT 235 FXTZ II 2011ACM北京网络赛 D题相关推荐

  1. HDU 5454 Excited Database (2015年沈阳赛区网络赛E题)

    1.题目描述:点击打开链接 2.解题思路:本题利用线段树解决,根据题意,我们需要建立两棵线段树,分别维护主对角线,副对角线.每个线段树的结点需要维护sum,sumL,sumR,其中,sum表示当前区间 ...

  2. HihoCoder 1835 K-Dimensional Foil II ICPC2018 北京网络赛

    http://www.cnblogs.com/DevilInChina/p/9691126.html 这个dalao 的思路 设平移球心到原点后 当前飞船坐标为 p(y_1,y_2,..,y_k) 球 ...

  3. HDU 5882 Balanced Game(2016亚洲区青岛站网络赛)

    题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5882 水题,直接奇偶性判断即可. #include <cstdio> #inc ...

  4. HDU 5025 Saving Tang Monk(广州网络赛D题)

    HDU 5025 Saving Tang Monk 题目链接 思路:记忆化广搜,vis[x][y][k][s]表示在x, y结点,有k把钥匙了,蛇剩余状态为s的步数,先把图预处理出来,然后进行广搜即可 ...

  5. ACM-ICPC 2018 北京网络赛:K-Dimensional Foil II

    #1835 : K-Dimensional Foil II 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 "K-Dimensional Foil" i ...

  6. ACM-ICPC 2018 北京网络赛:K-Dimensional Foil II 一题多解

    博客目录 原题 题目链接 #1835 : K-Dimensional Foil II 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 "K-Dimensional ...

  7. HDU - 5875 2016 ACM/ICPC 大连网络赛 H题 暴力

    题目链接 题意:给你一个区间l,r一直将val[l]模上val[l+1],val[l+2]...val[r],因为一个模上比前一个数小数是没有意义的,所以需要将每一个点找到右边第一个小于他的点就行. ...

  8. HDU - 5876 Sparse Graph 2016 ACM/ICPC 大连网络赛 I题 bfs+set+补图最短路

    题目链接 题意:给的补图,让你求一个源点到其他点的最短距离,因为图太稠密了, 用dij以及spfa根本不得行,这里只能用一种我不会方法来进行,这里用了bfs的方法以及set来维护,分别set维护一个未 ...

  9. HDU - 5877 Weak Pair 2016 ACM/ICPC 大连网络赛 J题 dfs+树状数组+离散化

    题目链接 You are given a rootedrooted tree of NN nodes, labeled from 1 to NN. To the iith node a non-neg ...

最新文章

  1. 【Netty】Netty线程模型和EventLoop
  2. 计算机二级考试vb内容,计算机二级考试VB重点内容.doc
  3. Web Service 与 RESTful Web Service比较
  4. 思科c240 m3 服务器安装系统,2U机架式 思科UCS C240 M3让你心动
  5. LeetCode 153. 寻找旋转排序数组中的最小值(二分)
  6. 普通人学python有啥用-学习Python到底有什么用?
  7. Linux下用dd命令测试硬盘的读写速度
  8. Phoenix 升級报Cluster is being concurrently upgraded from 4.9.x to 4.13.x 错误
  9. 【愚公系列】2022年04月 编码解码-摩尔斯电码和栅栏密码
  10. bootstarp怎么使盒子到最右边_8+ | 从恐龙特急克塞号到小猪佩奇,怎么都有它
  11. 力扣 旋转字符串 C语言 题解
  12. 【部分翻译】NSBezierPath的基础知识
  13. 关掉Windows10的计划自动重启行之有效的方法
  14. DDOS为什么是黑客通俗的攻击手段呢?
  15. 数据库实习总结1-1
  16. 均值滤波器类型_图像处理基础(3):均值滤波器及其变种
  17. 使用 VS Studio 2022 创建自己的 NuGet包,图片教程包教包会!
  18. MATLAB--数字图像处理 HOG+SVM识别手写数字
  19. 一步步带你做vue后台管理框架(二)——上手使用 系列教程《一步步带你做vue后台管理框架》第二课
  20. 【程序员2公务员】关于体制调研的一些常见问题总结

热门文章

  1. Rocket.chat快速安装部署
  2. Slumdog Millionaire--《贫民窟的百万富翁》
  3. 色调,饱和度,亮度如何计算
  4. 计算机视觉PyTorch迁移学习 - (二)
  5. FPGA流水灯(间隔1S)
  6. Centos7 本地IOS配置本地yum源
  7. 电子商务竞争加速:顺丰速运及天极均推B2C平台
  8. 利用 Automator 让 aira2 开机自启
  9. 浪潮优派培训笔记:Tomcat服务器
  10. JQuery显示和隐藏div