bishops专题

Codeforces 463C Gargari and Bishops

题意: 在一个n*n的矩阵中,让你选择两个点,使得两点所在的主对角线和斜对角线所包含的元素值之和最大。两点的对角线不能相交于同一个点。 思路: 一开始就被不能相交于同一个点难住了。后来问了铭神,二维矩阵其实是个二分图,就好比黑白染色。 先预处理出两种对角线的和,根据下面两条性质。 主对角线:横纵坐标相减的结果是相等的。 斜对角线:横纵坐标的和是相等的。 横纵坐标的和的奇偶性决定它们的

codeforces C#264. Gargari and Bishops

Gargari is jealous that his friend Caisa won the game from the previous problem. He wants to prove that he is a genius. He has a n × n chessboard. Each cell of the chessboard has a number written on

hdoj 1819 Bishops

其实,答案就是2(n - 1)。 写个大数而已。熟悉一下java的大数吧算是,很有用,却会忘…… import java.math.BigInteger;import java.util.*;public class Hdoj1819 {public static void main(String args[]) {BigInteger two = new BigInteger("2