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 ...
随机推荐
- 慧都独家披露DevExpress v13.2测试版重大变化
昨日,DevExpress隆重宣布发布v13.2.3测试版,想抢先尝鲜的朋友可以在这里下载哦.希望使用DevExpress旧版本的朋友,看到这些更新后能尽快更新你的代码,以免造成不必要的麻烦. Das ...
- 解析posix与perl标准的正则表达式区别
解析posix与perl标准的正则表达式区别 作者: 字体:[增加 减小] 类型:转载 本篇文章是对posix与perl标准的正则表达式区别进行了详细的分析介绍,需要的朋友参考下 正则表达式(Regu ...
- haskell io模块
haskell中的io模块主要是用于读写文件屏幕的,通过import IO来导入 其中有如下常用定义 data IOMode = ReadMode | WriteMode | AppendMode | ...
- C#设计模式(4)——抽象工厂模式
一.引言 在上一专题中介绍了工厂方法模式,工厂方法模式是为了克服简单工厂模式的缺点而设计出来的,简单工厂模式的工厂类随着产品类的增加需要增加额外的代码),而工厂方法模式每个具体工厂类只完成单个实例的创 ...
- JS编程常识
一.UI层的松耦合 松耦合就是要求各层遵循“最少知识原则”,或者说是各层各司其职,不要越权: HTML:结构层 CSS:表现层 JS:行为层 对于各层的职能,有一句比较贴切的解释:HTML是名词(n) ...
- EntityFramework 中支持 BulkInsert 扩展
本文为 Dennis Gao 原创技术文章,发表于博客园博客,未经作者本人允许禁止任何形式的转载. 前言 很显然,你应该不至于使用 EntityFramework 直接插入 10W 数据到数据库中,那 ...
- [MSSQL2005]再看CTE
个人认为CTE最大的做点是可以处理树状存储的数据了 例如类似这样设计的数据表,ID,ParentID这样的设计使用CTE就非常方便,原因就是CTE可以自引用,达到类似递归的效果 那么问题来了,如何使用 ...
- why add \n to http response.responseText
这是今天我们公司线上出现的问题,http response 的信息,都添加了一个\n换行,我找了好久呢 才发现,我把php页面的结束符?>去掉之后,一切正常,这个?>,我平时也是很少加上的 ...
- [JS13] ActivetX
<HTML> <head> <title>JavaScript Unleashed</title> <script type="text ...
- [算法] [常微分方程] [欧拉法 改进欧拉法 经典R-K算法]
#include<iostream> #include<cmath> #include<cstdio> #include<iomanip> using ...