HDU4762Cut the Cake(概率)
来源:互联网 发布:阿里云备案客服 编辑:程序博客网 时间:2024/05/19 00:37
题目链接:
http://acm.hdu.edu.cn/showproblem.php?pid=4762
题意:
将一个原型蛋糕分成m份扇形,然后使n个草莓恰好在其中的一份上
分析:
我们从中先取出一个来有n种选择,然后剩下的n-1个草莓在其极角[0,360/m]的范围内。
一个的概率为1/m,n-1个的概率为1/m^(n-1);
因此总的概率为n/m^(n-1).,因为20^20超过了longlong, 需要用高精度
代码如下:
//package fuck;import java.math.BigInteger;import java.util.Scanner;public class Main {static BigInteger gcd(BigInteger a,BigInteger b){if(!b.equals(BigInteger.ZERO)) return gcd(b,a.mod(b));return a;} public static void main(String args[]){ Scanner cin=new Scanner(System.in); int t = cin.nextInt(); while(t>0){ int m = cin.nextInt(); int n = cin.nextInt(); BigInteger N = BigInteger.valueOf(n); BigInteger M = BigInteger.valueOf(m).pow(n-1); BigInteger tmp = gcd(N,M); System.out.println(N.divide(tmp)+"/"+M.divide(tmp)); t--; } } }
0 0
- HDU4762Cut the Cake(概率)
- hdu4762Cut the Cake(概率+大数操作(java)+C++高精度模板)
- [概率]Cut the Cake
- HDU 4762-Cut the Cake(概率+高精度)
- HDOJ 4762 Cut the Cake(概率+Java)
- hdu 4762 Cut the Cake (概率 + java大数)
- hdu 4762 Cut the Cake(高精度&概率)
- hdu 4762 Cut the Cake 概率(2013 ACM/ICPC Asia Regional Changchun Online 1004)
- HDU 4762 Cut the Cake(概率+推理+高精度)
- 【HDOJ 4762】 Cut the Cake (数学概率+大数)
- HDu 4762 Cut the Cake 概率(推公式,积分)
- Cut the Cake(大数)
- hdu 4762 Cut the Cake(高精度)
- hdu4762 Cut the Cake(高次幂)
- [HDU 4328] Cut the cake (悬链法)
- HDU 4762 Cut the Cake (数学概率) 2013 ACM/ICPC 长春网络赛
- hoj2134 Cuts the cake
- HDU2134:Cuts the cake
- Apache Solr查询语法
- 第三章 20题 21题
- android的横竖屏切换
- 【STL源码剖析读书笔记】【第4章】序列式容器之list和slist
- Session的生命周期
- HDU4762Cut the Cake(概率)
- 嵌入式的学习规划
- BFS--- HDU 1240 Asteroids! 广度优先搜索
- 深入剖析Spring架构与设计原理(二)
- cocos2dx + android点击返回键两下退出游戏实现
- PLSQL没有“登录为“选项 ,并且监听程序当前无法识别连接描述符中请求的服务
- C#获取当前文件的路经
- MAVEN打包所遇问题集合
- <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>意义