HDU6415_Rikka with Nash Equilibrium
找规律 + 大数
由于规律会被取模破坏,所以用了java
//package acm; import java.math.BigInteger; import java.awt.Container; import java.math.*; import java.math.BigInteger; import java.util.*; import org.omg.PortableServer.ID_ASSIGNMENT_POLICY_ID; public class Main { public static void main(String[] args) { Scanner cin=new Scanner(System.in); int t = cin.nextInt(); for(int i=1;i<=t;i++) { int n = cin.nextInt(); int m = cin.nextInt(); BigInteger k = cin.nextBigInteger(); if(n==1) { BigInteger ans = BigInteger.ONE; for(int j=1;j<=m;j++) { ans = ans.multiply(BigInteger.valueOf(j)); } ans = ans.mod(k); System.out.println(ans); } else { BigInteger ans1 = BigInteger.ONE; for(int j=1;j<=n;j++) { ans1 = ans1.multiply(BigInteger.valueOf(j)); } //System.out.println(ans1); for(int j=2;j<=m;j++) { BigInteger tt = BigInteger.valueOf(j*n); BigInteger temp = BigInteger.ONE; for(int kk=0;kk<n;kk++) { temp = temp.multiply(tt.subtract(BigInteger.valueOf(kk))); } ans1 = ans1.multiply(temp); ans1 = ans1.multiply(BigInteger.valueOf(j)).divide(BigInteger.valueOf(j+n-1)); } ans1 = ans1.mod(k); System.out.println(ans1); } } cin.close(); } }