CSUOJ 1102 多色块拼图(进制转换,脑洞略大)
2014-11-20 11:41
141 查看
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(); } }
相关文章推荐
- CSU1102 多连块拼图 湖南第七届省赛
- CSU 1102 多连块拼图
- csuoj X - Rectangles (公式推导或者二分)
- bzoj4592 脑洞治疗仪 线段树
- 九度 1138 - 大数除余 - 进制转换
- 【BFS】coj 1061 【魔方系列】最大色块
- Codeforce#424E. Cards Sorting(脑洞+树状数组)
- PAT a1102题解
- hdu 2031 进制转换
- 进制转换(栈 && 16进制转换)
- 壮志难酬 HUD-2549【脑洞。。。】
- 进制转换
- 51Nod-1030-大数进制转换
- 进制转换(未完待续)
- 进制转换
- 1102:平方和与立方和
- 【脑洞系列】C语言基础之刷屏系统的简单实现
- PAT-1058 A+B in Hogwarts (进制转换)
- 脑洞蒙特卡洛模型,来招聘
- 汇编语言程序设计知识点(第一章:进制转换)