HDU4762 Cut the Cake
Posted solvit
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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的主要内容,如果未能解决你的问题,请参考以下文章
You Are the One HDU - 4283(区间dp)