刚开始以为是搜索白忙活了原来是个简单的找规律,以后要多想啊

此题是两马同时跳

A. Two Semiknights Meet
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

A boy Petya loves chess very much. He even came up with a chess piece of his own, a semiknight. The semiknight can move in any of these four directions:2 squares forward and
2 squares to the right,2 squares forward and
2 squares to the left,2 squares backward and
2 to the right and2 squares backward and
2 to the left. Naturally, the semiknight cannot move beyond the limits of the chessboard.

Petya put two semiknights on a standard chessboard. Petya simultaneously moves with both semiknights. The squares are rather large, so after some move the semiknights can meet, that is, they can end up in the same square. After the meeting the semiknights
can move on, so it is possible that they meet again. Petya wonders if there is such sequence of moves when the semiknights meet. Petya considers some squares bad. That is, they do not suit for the meeting. The semiknights can move through these squares but
their meetings in these squares don't count.

Petya prepared multiple chess boards. Help Petya find out whether the semiknights can meet on some good square for each board.

Please see the test case analysis.

Input

The first line contains number t (1 ≤ t ≤ 50) — the number of boards. Each board is described by a matrix of characters, consisting of 8 rows and 8 columns. The matrix consists
of characters ".", "#", "K", representing an empty good square, a bad square and the semiknight's position, correspondingly. It is guaranteed
that matrix contains exactly 2 semiknights. The semiknight's squares are considered good for the meeting. The tests are separated by empty line.

Output

For each test, print on a single line the answer to the problem: "YES", if the semiknights can meet and "NO" otherwise.

Sample test(s)
Input
2
........
........
......#.
K..##..#
.......#
...##..#
......#.
K....... ........
........
..#.....
..#..#..
..####..
...##...
........
....K#K#
Output
YES
NO
Note

Consider the first board from the sample. We will assume the rows and columns of the matrix to be numbered 1 through 8 from top to bottom and from left to right, correspondingly. The knights can meet, for example, in square (2,7).
The semiknight from square (4,1) goes to square (2,3) and the semiknight goes from square (8,1)
to square (6, 3). Then both semiknights go to (4,
5) but this square is bad, so they move together to square (2,7).

On the second board the semiknights will never meet.

http://blog.csdn.net/firwaless/article/details/16342823

#include<stdio.h>

#include<math.h>

int main() {

int m,i,j,t,startx,starty,endx,endy;

char s[10][10];

scanf("%d",&t);

while(t--) {

for(i=1;i<=8;i++)

scanf("%s",s[i]+1);

m=0;

for(i=1;i<=8;i++)

for(j=1;j<=8;j++) {

if(s[i][j]=='K'&&m==0) {

m=1;

startx=i;

starty=j;

}

else

if(s[i][j]=='K') {

endx=i;

endy=j;

}

}

startx=abs(startx-endx);

endx=abs(starty-endy);

if(startx%4==0&&endx%4==0)

printf("YES\n");

else

printf("NO\n");

}

return 0;

}

codeforces 362A找规律的更多相关文章

  1. codeforces D. Queue 找规律+递推

    题目链接: http://codeforces.com/problemset/problem/353/D?mobile=true H. Queue time limit per test 1 seco ...

  2. Codeforces Gym 100114 A. Hanoi tower 找规律

    A. Hanoi tower Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Descript ...

  3. Tetrahedron(Codeforces Round #113 (Div. 2) + 打表找规律 + dp计数)

    题目链接: https://codeforces.com/contest/166/problem/E 题目: 题意: 给你一个三菱锥,初始时你在D点,然后你每次可以往相邻的顶点移动,问你第n步回到D点 ...

  4. 找规律/贪心 Codeforces Round #310 (Div. 2) A. Case of the Zeros and Ones

    题目传送门 /* 找规律/贪心:ans = n - 01匹配的总数,水 */ #include <cstdio> #include <iostream> #include &l ...

  5. 找规律 Codeforces Round #309 (Div. 2) A. Kyoya and Photobooks

    题目传送门 /* 找规律,水 */ #include <cstdio> #include <iostream> #include <algorithm> #incl ...

  6. codeforces B. A and B 找规律

    Educational Codeforces Round 78 (Rated for Div. 2) 1278B - 6 B. A and B  time limit per test 1 secon ...

  7. Codeforces D. Little Elephant and Interval(思维找规律数位dp)

    题目描述: Little Elephant and Interval time limit per test 2 seconds memory limit per test 256 megabytes ...

  8. Codeforces 193E - Fibonacci Number(打表找规律+乱搞)

    Codeforces 题目传送门 & 洛谷题目传送门 蠢蠢的我竟然第一眼想套通项公式?然鹅显然 \(5\) 在 \(\bmod 10^{13}\) 意义下并没有二次剩余--我真是活回去了... ...

  9. 找规律 Codeforces Round #290 (Div. 2) A. Fox And Snake

    题目传送门 /* 水题 找规律输出 */ #include <cstdio> #include <iostream> #include <cstring> #inc ...

随机推荐

  1. IOS利用Core Text对文字进行排版 - 转

    原贴地址:http://hi.baidu.com/jwq359699768/blog/item/5df305c893413d0a7e3e6f7b.html core text 这个包默认是没有的,要自 ...

  2. 203 Remove Linked List Elements 删除链表中的元素

    删除链表中等于给定值 val 的所有元素.示例给定: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6返回: 1 --& ...

  3. Android开发学习——高德地图的实现

    1.首先做好下边的准备: 1.1  http://lbs.amap.com/   注册账号 1.2  下载 定位sdk 和 地图sdk 下载后是这样的 1.3  对下载的进行解压 将他们加入 中,对每 ...

  4. composer Failed to decode zlib stream 无法解码zlib流

    Win7 中安装 Composer (PHP) 国内有些网络不能访问美国的Composer官网,可访问 Composer 中文网 学习. 目标 可以在任何目录下的项目中执行 PHP composer. ...

  5. 程序猿工具——svn

    一个项目的产生,都需要团队中的开发人员互相协作.它的简单,方便深深吸引了我. svn的使用,有2部分组成--svn服务器.svn客户端.svn服务器一般团队之间只要有一个安装就可以了. 在学习安装sv ...

  6. LN : leetcode 118 Pascal's Triangle

    lc 118 Pascal's Triangle 118 Pascal's Triangle Given numRows, generate the first numRows of Pascal's ...

  7. vue组件、数据解析的实现思想猜想与实践

    Vue的全局组件,在注册后,可在全局范围内无限次使用,猜想是利用了闭包"可以保持形参"的特性,使初始化时的作用域得意保存,下面用原生js和部分jquery代码模拟了数据解析和组件渲 ...

  8. vuex使用之state访问状态对象

    引入vuex1.利用npm包管理工具,进行安装 vuex.在控制命令行中输入下边的命令就可以了. npm install vuex --save 需要注意的是这里一定要加上 –save,因为你这个包我 ...

  9. iOS微信页面 长按图片出现【存储图像】和【拷贝】不出现【发送朋友】【保存图片】

    最近遇到一大坑.微信加载的页面中出现图片,长按图片时不出现默认的菜单[发送朋友]等而是[存储图像]和拷贝. 原因:正常在页面中长按图片是没有问题的,但是如果你的页面嵌入了ifram然后又长按在ifra ...

  10. 今天被 <!doctype html> 搞了两个小时,两个页面同样的样式,chosen右边的小箭头,一个上下居中对齐 一个居顶对齐。最后找到问题所在doctype

    今天被 <!doctype html> 搞了两个小时,两个页面同样的样式,chosen右边的小箭头,一个上下居中对齐 一个居顶对齐.最后找到问题所在doctype <-- 这个小箭头