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个草莓都在同一个扇形上的概率. ...
随机推荐
- Git005--工作区和暂存区
Git--工作区和暂存区 本文来自于:https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b0 ...
- 虚拟机环境搭建/修改VMware虚拟机固定IP
VMware Workstation安装CentOS7.0 详情教程: centos7.0下载地址:http://isoredirect.centos.org/centos/7/isos/x86_64 ...
- Using text search in Web page with Sikuli
在網頁中如何使用Sikuli找特定字串呢? 原理: 我們可以使用 組合鍵 ctrl + 來放大網頁的比例,使得sikuli的OCR功能找的更清準 實作: for i in range(4): type ...
- mint/ubuntu Android Eclipse ADT 简单安装及执行崩溃解决的方法
1. 下载 Android SDK(ADT Bundle) http://developer.android.com/sdk/index.html (站点訪问不了或者慢.请參考:轻松改 ...
- 使用网易云web 版外部链接
右击打开控制台,找到音乐列表 ——> 点开详情 -------> 生成外部链接器 ,如: outchain/0/3073492173 ,这是每一个音乐的编号. 然后拼接上它的官网域名 ...
- iview table列中根据不同的状态显示不同的颜色,显示图片
使用reder可以实现 1.显示不同状态 2.显示图片
- JavaScript—— 案例:表单验证
QQ号:<input type="text" id="txtQQ"><span></span><br> 邮箱:& ...
- 数组Array的方法调用
<script language="JavaScript" type="text/javascript"> var arr = ["11& ...
- 关于.net中使用reportview所需注意
参考文章链接:http://www.cnblogs.com/watercold/p/5258608.html 这段时间在做一个winform的小项目时,发现使用.net中的ReportViewer插件 ...
- WriteDataToFile(filename,pJsonData,strlen(pJsonData)+1)
WriteDataToFile(filename,pJsonData,strlen(pJsonData)+1) 字节流的长度计算 发送的txt 文件是对的 zip exe出现字节计算错误 strlen ...