HDU4762 Cut the Cake
阿新 • • 發佈:2018-10-03
mat pen acm cin public can ger treenode cli
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 { publicView Codestatic 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