HDU4762 Cut the Cake
思路:公式:n/m(n-1)
//package acm; import java.awt.Container;
import java.awt.geom.AffineTransform;
import java.math.*;
import java.util.*; import javax.swing.tree.TreeNode; import org.omg.PortableServer.ID_ASSIGNMENT_POLICY_ID; public class Main
{
public static BigInteger gcd(BigInteger a,BigInteger b) {
if(b.equals(BigInteger.ZERO)) {
return a;
}
else {
return gcd(b, a.mod(b));
}
}
public static void main(String[] args)
{
Scanner cin = new Scanner(System.in);
int t = cin.nextInt();
for(int cas = 0; cas < t; cas++)
{
BigInteger m = cin.nextBigInteger();
int n = cin.nextInt();
m = m.pow(n - 1);
BigInteger tn = BigInteger.valueOf(n);
BigInteger tt = gcd(tn, m);
tn = tn.divide(tt);
m = m.divide(tt);
System.out.println(tn + "/" + m);
}
cin.close();
}
}
HDU4762 Cut the Cake的更多相关文章
- HDU 4762 Cut the Cake(公式)
Cut the Cake Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tota ...
- Cut the Cake(大数相乘)
MMM got a big big big cake, and invited all her M friends to eat the cake together. Surprisingly o ...
- 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 4328 Cut the cake
Cut the cake Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tota ...
- hdu 4762 Cut the Cake (大数乘法)
猜公式: ans=n/m^(n-1) #include<stdio.h> #include<string.h> struct BigNum { ]; int len; }; i ...
- 【HDOJ】4328 Cut the cake
将原问题转化为求完全由1组成的最大子矩阵.挺经典的通过dp将n^3转化为n^2. /* 4328 */ #include <iostream> #include <sstream&g ...
- HDU 4762 Cut the Cake
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4762 题目大意:将n个草莓随机放在蛋糕上,草莓被看做是点,然后将蛋糕平均切成m份,求所有草莓在同一块蛋 ...
- hdu 4762 Cut the Cake概率公式
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4762 题目大意:一个圆形蛋糕,现在要分成M个相同的扇形,有n个草莓,求n个草莓都在同一个扇形上的概率. ...
随机推荐
- 有意思的B+树漫画介绍
转载自:伯乐专栏作者/玻璃猫,微信公众号 - 梦见 漫画:什么是b+树 这一次我们来介绍 B+ 树. 一个m阶的B树具有如下几个特征: 1.根结点至少有两个子女. 2.每个中间节点都包含k-1个元素和 ...
- c#处理json格式类型的字符串
string channelGroup=[{"SpType":"1","BaseInfoId":["xxx"," ...
- 阿里云ECS服务器centos6.x安装docker问题盘点
1.首先在centos6.x和centos7.x中yum安装docker的区分. centos6.x: yum install docker-io centos7.x: yum install doc ...
- 解决Linux下Svn检出Windows SVN服务器上项目SSL handshake failed: SSL error: Key usage violation in certificate has been detected.
在Linux上检出windows SVN服务器上项目时出现了SSL handshake failed: SSL error: Key usage violation in certificate ha ...
- Vue的入门之安装
vue.js是前端框架中比较热门的,因为工作关系,也加入了浩浩荡荡的学习大潮中,用笔记记录下点滴,便于后面学习查阅! 1 node.js环境的安装包(npm包管理器) 2 vue-cli 脚手架构建工 ...
- 方法重载(overload)与方法重写(override)
一.方法重载: 在同一个类中,允许存在一个及以上的同名方法,只要他们的参数列表不同(参数的个数或者参数的类型不同)即可.注意方法重载与返回值类型.访问权限修饰符.和抛出的异常无关.重载是在本类中,与继 ...
- 使用Angular2+的内置管道格式化数据
在简书看到一篇关于Angualr运用内置管道格式化数据的总结,感觉挺实用的,转载一下以供参考: [转载]https://www.jianshu.com/p/a8bd5a1d2c53 PS:管道是在HT ...
- Django Rest Framewoek
1 什么是RESTful REST 指的是一种软件架构风格.设计风格,而不是标准,只是提供了一组设计原则和约束条件.满足这些约束条件和原则的应用程序或设计就是 RESTful. 2 RESTful设计 ...
- go 学习之io/ioutil包
// Discard 是一个 io.Writer 接口,调用它的 Write 方法将不做任何事情// 并且始终成功返回.var Discard io.Writer = devNull(0) // Re ...
- python学习三十七天函数的作用域查找顺序LEGB
python函数的作用域查找顺序LEGB,分别为 locals eclosing globals builtins .了解作用域的范围,可以更好的操作你想要的业务,分别介绍一下. 1,local ...