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. jmeter两种录制方式

    jmeter两种录制方式 一.Badboy Badboy是一款不错web自动化测试工具,利用它来录制脚本,并且录制的脚本可以直接保存为JMeter文件来使用. Badboy  version 2.1. ...

  2. python网络编程中互斥锁与进程之间的通信

    一.互斥锁 进程之间数据隔离,但是共享一套文件系统,因而可以通过文件来实现进程直接的通信,但问题是必须自己加锁处理. 注意:加锁的目的是为了保证多个进程修改同一块数据时,同一时间只能有一个修改,即串行 ...

  3. [Codeforces 280D]k-Maximum Subsequence Sum(线段树)

    [Codeforces 280D]k-Maximum Subsequence Sum(线段树) 题面 给出一个序列,序列里面的数有正有负,有两种操作 1.单点修改 2.区间查询,在区间中选出至多k个不 ...

  4. 32.Group Anagrams(相同元素的不同组合)

    Level:   Medium 题目描述: Given an array of strings, group anagrams together. Example: Input: ["eat ...

  5. MVC与设计模式的关系及MVC的实现原理和设计原理

    1 MVC介绍 众所周知MVC不是设计模式,是一个比设计模式更大一点的模式,称作设计模式不合理,应该说MVC它是一种软件开发架构模式,它包含了很多的设计模式,最为密切是以下三种:Observer (观 ...

  6. shell脚本-巡检内存使用率

    #!/bin/bash # by dreamer Q # 巡检内存脚本 #总内存大小 mem_total=`free -m | sed -n '2p' |awk '{print $2}'` #已使用内 ...

  7. ApacheHttpServer出现启动报错:the requested operation has failed解决办法

    转自:https://www.jb51.net/article/21004.htm 原因一:80端口占用 例如IIS,另外就是迅雷.我的apache服务器就是被迅雷害得无法启用! 原因二:软件冲突 装 ...

  8. 二、jquery Try{}catch(e){}

    一.Try{}catch(e){} try{ $.each($("div"),function(i,item){ if(...){ throw("异常信息"); ...

  9. [算法学习]开始leetcode之旅

    在此记录一下用javascript刷leetcode的过程,每天都要坚持! 1.Two Sum Given an array of integers, find two numbers such th ...

  10. Sass:字符串函数-To-upper-case()、To-lower-case()

    1.To-upper-case() To-upper-case() 函数将字符串小写字母转换成大写字母.如: //SCSS .test { text: to-upper-case(aaaaa); te ...