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的更多相关文章

  1. HDU 4762 Cut the Cake(公式)

    Cut the Cake Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  2. Cut the Cake(大数相乘)

      MMM got a big big big cake, and invited all her M friends to eat the cake together. Surprisingly o ...

  3. 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 ...

  4. HDU 4762 Cut the Cake(高精度)

    Cut the Cake Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  5. HDU 4328 Cut the cake

    Cut the cake Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Tota ...

  6. hdu 4762 Cut the Cake (大数乘法)

    猜公式: ans=n/m^(n-1) #include<stdio.h> #include<string.h> struct BigNum { ]; int len; }; i ...

  7. 【HDOJ】4328 Cut the cake

    将原问题转化为求完全由1组成的最大子矩阵.挺经典的通过dp将n^3转化为n^2. /* 4328 */ #include <iostream> #include <sstream&g ...

  8. HDU 4762 Cut the Cake

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4762 题目大意:将n个草莓随机放在蛋糕上,草莓被看做是点,然后将蛋糕平均切成m份,求所有草莓在同一块蛋 ...

  9. hdu 4762 Cut the Cake概率公式

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4762 题目大意:一个圆形蛋糕,现在要分成M个相同的扇形,有n个草莓,求n个草莓都在同一个扇形上的概率. ...

随机推荐

  1. [eclipse相关] 001 - 启动+运行优化

    本随笔参考了其他博客内容,且在验证有效之下才或誊抄或摘录或加上自己经验组合而成. 参考博客: 1,http://zwd596257180.gitee.io/blog/2019/04/17/eclips ...

  2. [CF643E]Bear and Destroying Subtrees(期望,忽略误差)

    Description: ​ 给你一棵初始只有根为1的树 ​ 两种操作 ​ 1 x 表示加入一个新点以 x为父亲 ​ 2 x 表示以 x 为根的子树期望最深深度 ​ 每条边都有 \(\frac{1}{ ...

  3. 两台centos,用yum install 安装,一台成功,一台失败

    记录一下问题: 两台centos,用yum install 安装软件,一台成功,一台失败 第一步:查看yum源  yum repolist enabled 疑问:centos安装的方法一致,但yum源 ...

  4. JavaScript常用字符串方法和属性

    一直以来  在喜马拉雅上听  陪你读书(JavaScript WEB前端)  主播沙翼 讲的很好  果断买了这本书  现在做个笔记 var str = ‘abcd’ str.charAt(0); // ...

  5. Python之文件路径名的操作

    使用 os.path 模块中的函数来操作路径名 import os # 获取当前文件路径 path=os.path.abspath(__file__) # 获取绝对路径 /home/zzy/Pycha ...

  6. k3 cloud中数值以百分比的形式展示

    显示格式化字符串:P去掉区域设置的勾选

  7. VUE小案例--跑马灯效果

    自学Vue课程中学到的一个小案例,跑马灯效果 <!DOCTYPE html> <html lang="zh-CN"> <head> <me ...

  8. JavaScript 内置对象 Array 数组

    Array 数组 1.创建数组 构造函数 new Array() 小括号内可以是数组元素个数,也可以是数组项 数组字面量表示法 var arr = [1,2,3,4,5]; 2.数组长度 arr.le ...

  9. Oracle连接远程数据库

    我用的事navicat连接工具 方法一: 找到  工具---->环境,OCI环境 选择中间那个(我的是这个,我不确定是不是都一样,可以都试试),选好之后关闭navicat,重新运行navicat ...

  10. 【ASE高级软件工程】Alpha 阶段 backend组 scrum1 记录

    本次会议于11月4日,19:10 在微软北京西二号楼13478召开,持续40分钟. 与会人员:Haifeng Chen, Zhikai Chen, Hao Wang, Jia Ning 请假: Xin ...