题意很简单就不说了。

解题的关键就是这个公式

answer=n/(m^(n-1));

要用到大数的乘法。然后java水过。

import java.util.*;
import java.math.*; public class Main {
public static BigInteger gcd (BigInteger a, BigInteger b) {
if (a.mod(b).equals(BigInteger.valueOf(0)))
return b;
return gcd(b, a.mod(b));
}
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
int t = cin.nextInt();
BigInteger a, b, c;
int n, m;
while (t--!= 0) {
m = cin.nextInt();
n = cin.nextInt();
a = BigInteger.valueOf(1);
for (int i = 1; i < n; i++)
a = a.multiply(BigInteger.valueOf(m));
b = BigInteger.valueOf(n);
c = gcd(a, b);
System.out.println(b.divide(c) + "/" + a.divide(c));
}
cin.close();
}
}

hdoj 4762 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. 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 ...

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

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

  4. HDU 4762 Cut the Cake

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

  5. hdu 4762 Cut the Cake概率公式

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

  6. 2013长春网赛1004 hdu 4762 Cut the Cake

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4762 题意:有个蛋糕,切成m块,将n个草莓放在上面,问所有的草莓放在同一块蛋糕上面的概率是多少.2 & ...

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

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

  8. Cut the Cake(大数相乘)

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

  9. HDU 4328 Cut the cake

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

随机推荐

  1. 在 Angular 2 Component 中使用第三方 JS 库

    本文所有内容以 Angular 2 Quick Start 项目为基础,使用 TypeScript 语言. 如上图,最近遇到一个需求,需要在一个刚启动的 Angular 2 项目中使用 snap.sv ...

  2. 一文秒懂CPU使用率

    目录 CPU:Cores, and Hyper-Threading  超线程(Hyper-Threading ) 多核(multi-cores) CPU使用率计算 CPU使用率测试 如何计算CPU使用 ...

  3. 建立自己composer私有仓库

    创建仓库地址以gitee为例,主要github太慢 本地建立一个项目目录,然后初始化 composer init 然后根路径下创建src/util目录 修改composer.json,设置autolo ...

  4. Windows 命令行文本操作

    Windows下文件操作,大部分的时候用的都是用Windows 资源管理器(就是双击 “我的电脑” 的时候看到的图形界面). 接下来,以Windows命令行下操作文本为例,看看命令行在操作文件方面有多 ...

  5. Google play中下载apk

    在 Google play中下载apk:先在Google play中找到该apk,再去找APK downloader(https://www.allfreeapk.com/),Google play的 ...

  6. JAVA UUID 生成唯一密钥(可随机选择长度)

    /**     * 获得指定数目的UUID      * @param number int 需要获得的UUID数量      * @return String[] UUID数组      */    ...

  7. js常用设计模式实现(一)单例模式

    前言 什么是设计模式 设计模式是一种能够被反复使用,符合面向对象特性的代码设计经验的总结,合理的使用设计模式能够让你得代码更容易维护和可靠 设计模式的类型共分为创建型模式,结构型模式,行为型模式三种 ...

  8. Java中的关键字synchronized

    1. 介绍 在Java并发系列的文章中,这个是第二篇文章.在前面的一篇文章中,我们学习了Java中的Executor池和Excutors的各种类别. 在这篇文章中,我们会学习synchronized关 ...

  9. 1. 全文搜索框架 Haystack

    1.什么是Haystack Haystack是django的开源全文搜索框架(全文检索不同于特定字段的模糊查询,使用全文检索的效率更高 ),该框架支持Solr,Elasticsearch,Whoosh ...

  10. 不要再问我Java程序是怎么执行的了!

    什么是Java虚拟机? 要弄明白Java程序的执行过程首先要了解一下Java虚拟机 虚拟机是一种抽象化的计算机,通过在实际的计算机上仿真模拟各种计算机功能来实现的.Java虚拟机有自己完善的硬体架构, ...