1. 程式人生 > >HDU4762 Cut the Cake

HDU4762 Cut the Cake

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
{    
    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(); } }
View Code

HDU4762 Cut the Cake