RE,暂存。(大概是字符串的处理不对,如果能帮鄙人指正错误,当感激不尽。。)
import java.io.*; import java.math.*; import java.util.*; public class Main { public static BigInteger get_Value(char Matrix[][], int n, int base) { BigInteger ret = BigInteger.ZERO; for(int i = n - 1; i >= 0; i--) for(int j = n - 1; j >= 0; j--) { ret = ret.multiply(BigInteger.valueOf(base)); if(Matrix[i][j] == '*') ret = ret.add(BigInteger.ONE); } return ret; } public static void main(String[] args) //throws Exception { //FileInputStream fp = new FileInputStream("1102.in"); //System.setIn(fp); Scanner cin = new Scanner(new BufferedInputStream(System.in)); while(true) { int n = cin.nextInt(); int m = cin.nextInt(); if(n == 0 && m == 0) break; char[][] Board = new char[20][20]; char[][] Piece = new char[20][20]; String add = ""; for(int i = m; i < n; i++) add = add + "."; for(int i = 0; i < n; i++) Board[i] = cin.next().toCharArray(); for(int i = 0; i < m; i++) Piece[i] = (cin.next() + add).toCharArray(); BigInteger checkBoard_1 = get_Value(Board, n, 2); BigInteger checkBoard_2 = get_Value(Board, n, 3); BigInteger checkPiece_1 = get_Value(Piece, n, 2); BigInteger checkPiece_2 = get_Value(Piece, n, 3); if(checkPiece_1.compareTo(BigInteger.ZERO) == 0 || checkPiece_2.compareTo(BigInteger.ZERO) == 0) System.out.println(0); else if((checkBoard_1.remainder(checkPiece_1).compareTo(BigInteger.ZERO) == 0) && (checkBoard_2.remainder(checkPiece_2).compareTo(BigInteger.ZERO) == 0)) System.out.println(1); else System.out.println(0); } cin.close(); } }