package yukicoder; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; public class P659 { static double [][] pow(double[][] A, long n) { if(n==1) { return A; } if(n%2==0) { double[][] B = pow(A, n/2); return mul(B, B); } else { double[][] B = mul(A, pow(A, n-1)); return B; } } static double[][] mul(double [][] A, double [][] B) { assert A[0].length == B.length; int n = A.length; int k = A[0].length; int m = B[0].length; double[][] C = new double[n][m]; for(int i=0; i