HDU 4762 Cut the Cake(公式)
Cut the Cake
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 263    Accepted Submission(s): 113
For each case, two integers M, N indicate the number of her friends and the number of strawberry.
(2 < M, N <= 20, T <= 400)
3 3
3 4
4/27
公式为:n/m^(n-1)
import java.util.Scanner;
import java.math.BigInteger; public class Main{
public static void main(String[] args){
Scanner cin = new Scanner(System.in);
int t = cin.nextInt();
while(t!=0){
t--;
BigInteger m = cin.nextBigInteger();
int n = cin.nextInt();
BigInteger tmp=BigInteger.valueOf(n);
BigInteger ans=m.pow(n-1);
BigInteger x=ans.gcd(tmp);
System.out.println(tmp.divide(x) + "/" + ans.divide(x));
}
}
}
HDU 4762 Cut the Cake(公式)的更多相关文章
- HDU 4762 Cut the Cake (2013长春网络赛1004题,公式题)
		Cut the Cake Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tota ... 
- HDU 4762 Cut the Cake(高精度)
		Cut the Cake Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tota ... 
- hdu 4762 Cut the Cake概率公式
		题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4762 题目大意:一个圆形蛋糕,现在要分成M个相同的扇形,有n个草莓,求n个草莓都在同一个扇形上的概率. ... 
- HDU 4762 Cut the Cake
		题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4762 题目大意:将n个草莓随机放在蛋糕上,草莓被看做是点,然后将蛋糕平均切成m份,求所有草莓在同一块蛋 ... 
- 2013长春网赛1004 hdu 4762 Cut the Cake
		题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4762 题意:有个蛋糕,切成m块,将n个草莓放在上面,问所有的草莓放在同一块蛋糕上面的概率是多少.2 & ... 
- hdu 4762 Cut the Cake (大数乘法)
		猜公式: ans=n/m^(n-1) #include<stdio.h> #include<string.h> struct BigNum { ]; int len; }; i ... 
- HDU  4328  Cut the cake
		Cut the cake Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tota ... 
- hdoj 4762 Cut the Cake
		题意很简单就不说了. 解题的关键就是这个公式 answer=n/(m^(n-1)); 要用到大数的乘法.然后java水过. import java.util.*; import java.math.* ... 
- HDU 2134 Cuts the cake
		http://acm.hdu.edu.cn/showproblem.php?pid=2134 Problem Description Ice cream took a bronze medal in ... 
随机推荐
- Java文件内容的复制
			package a.ab; import java.io.*; public class FileReadWrite { public static void main(String[] args) ... 
- ubuntu卸载java
			Try this command: java -version If 1.6* comes then try: sudo apt-get autoremove openjdk-6-jre If 1.7 ... 
- Web 开发中 20 个很有用的 CSS 库
			转自:http://www.oschina.net/translate/css-libraries-for-developers 在过去的几年中,CSS已经成为一大部分开发者和设计者的最爱,因为它提供 ... 
- 设计模式之美:Factory Method(工厂方法)
			索引 别名 意图 结构 参与者 适用性 缺点 效果 相关模式 命名约定 实现 实现方式(一):Creator 类是一个抽象类并且不提供它所声明的工厂方法的实现. 实现方式(二):Creator 类是一 ... 
- Kindle 转换器
			一款比较好用的Kindle转换器,支持txt, opf, htm, html, epub 到 mobi 的转换,支持拖放操作,支持批量操作.只需要选中多个待转换的文件,拖放到程序窗口即可. 曾经用过一 ... 
- Win32 多线程学习笔记
			学到的API函数 一.线程 创建线程.结束线程.获取线程的结束码 CreateThread ExitThread GetExitCodeThread 二.线程结束时触发 创建线程之后,等待线程的结束之 ... 
- git查看一个文件的历史记录
			git log --all -- '*'FILENAME'*' 支持模糊查询 主要用于查找历史上被删除的文件 可以做成git的一个快捷命令 find = "!f(){ git log --a ... 
- js语法
			需要<script language="javascript">标签: ||或者:二选一,满足为true.,否则为false &&与:同时满足,即为tr ... 
- [Java拾遗五]使用Session防止表单重复提交
			申明:此文章属于转载, 转自博客: http://www.cnblogs.com/xdp-gacl/p/3859416.html在平时开发中,如果网速比较慢的情况下,用户提交表单后,发现服务器半天都没 ... 
- atitit.泛型编程总结最佳实践 vO99 java c++ c#.net php
			atitit.泛型编程总结最佳实践 vO99 java c++ c#.net php \ 1. 泛型历史 1 由来 1 2. 泛型的机制编辑 1 机制 1 编译机制 2 3. 泛型方法定义1::前定义 ... 
