题目链接:https://vjudge.net/contest/28079#problem/B 题目大意:给你一个nxm的棋盘,问你最多可以放几个骑士让他们互相攻击不到.骑士攻击方式如下图: 解题思路:当m和n都大于2时,ans=(m*n+1)/2 当m或n有一个为1时,ans=m*n 当m或n有一个为2时,那么我们可以考虑可以分出多少个2*2的格子(t田字格) ,那么我们可以一次把一个田字格全部放上马,然后间隔一个田字格,然后再放马,使m=max(n,m),判断田字格两两匹配后剩下的格子数tm…
1010 - Knights in Chessboard    PDF (English) Statistics Forum Time Limit: 1 second(s) Memory Limit: 32 MB Given an m x n chessboard where you want to place chess knights. You have to find the number of maximum knights that can be placed in the chess…
题目连接: http://www.lightoj.com/volume_showproblem.php?problem=1010 题目描述: 有一个n*m的棋盘,根据象棋中马走日字的规则,问此棋盘最多可以存放多少个马,并且任意两个马之间不会相互攻击. 解题思路: 从题目中给的棋盘可以看出,如果我们只把马放在白格子或者只把马放在黑格子的话都是合法的,但是是不是最优呢? 仔细考虑一下就可以得出: 当min(n, m) == 1的时候,把格子放满马也是没事的, 当min(n, m) == 2的时候,可…
lightoj 1010 Knights in Chessboard 链接:http://lightoj.com/volume_showproblem.php?problem=1010 题意:国际象棋规则,在 m*n 的格子放某一棋子,棋子可以沿着它的8个方位直走,问盘子可以放多少个这样的棋子而使任意两个不发生冲突. 思路:数学水题,找下算出几组,找下规律就出来了.值得注意的是有特判. 代码: #include <iostream> #include <cstdio> #inclu…
题目 Source http://www.lightoj.com/volume_showproblem.php?problem=1171 Description Given an m x n chessboard where some of the cells are broken. Now you are about to place chess knights in the chessboard. You have to find the maximum number of knights…
Given an m x n chessboard where you want to place chess knights. You have to find the number of maximum knights that can be placed in the chessboard such that no two knights attack each other. Those who are not familiar with chess knights, note that…
1.LightOJ 1245   Harmonic Number (II)   数学题 2.总结:看了题解,很严谨,但又确实恶心的题 题意:求n/1+n/2+....+n/n,n<=2^31. #include<iostream> #include<cstring> #include<cmath> #include<queue> #include<algorithm> #include<cstdio> #define max(a…
题目链接:https://vjudge.net/contest/28079#problem/P 题目大意:给你数组A[]以及如下所示的函数f: long long f( int A[], int n ) { // n = size of A long long sum = 0; for( int i = 0; i < n; i++ ) for( int j = i + 1; j < n; j++ ) sum += A[i] - A[j]; return sum; } 有两个操作:0  x  v…
链接: https://vjudge.net/problem/LightOJ-1369 题意: The problem you need to solve here is pretty simple. You are give a function f(A, n), where A is an array of integers and n is the number of elements in the array. f(A, n) is defined as follows: long lo…
题意,在一个n*n的棋盘上放置一些马,使这些马不能互相攻击,问最多能放多少. 思路:从第一行每隔一个放置一个马即可,注意n=1和n=2的情况要特判. #include<cstdio> int main(){ int n, m, t; scanf("%d", &t); for(int i = 1;i <= t;i ++){ scanf("%d%d", &n, &m); printf("Case %d: ",…