codeforces 362A找规律
刚开始以为是搜索白忙活了原来是个简单的找规律,以后要多想啊
此题是两马同时跳
1 second
256 megabytes
standard input
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.
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.
For each test, print on a single line the answer to the problem: "YES", if the semiknights can meet and "NO" otherwise.
2
........
........
......#.
K..##..#
.......#
...##..#
......#.
K....... ........
........
..#.....
..#..#..
..####..
...##...
........
....K#K#
YES
NO
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找规律的更多相关文章
- codeforces D. Queue 找规律+递推
题目链接: http://codeforces.com/problemset/problem/353/D?mobile=true H. Queue time limit per test 1 seco ...
- Codeforces Gym 100114 A. Hanoi tower 找规律
A. Hanoi tower Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Descript ...
- Tetrahedron(Codeforces Round #113 (Div. 2) + 打表找规律 + dp计数)
题目链接: https://codeforces.com/contest/166/problem/E 题目: 题意: 给你一个三菱锥,初始时你在D点,然后你每次可以往相邻的顶点移动,问你第n步回到D点 ...
- 找规律/贪心 Codeforces Round #310 (Div. 2) A. Case of the Zeros and Ones
题目传送门 /* 找规律/贪心:ans = n - 01匹配的总数,水 */ #include <cstdio> #include <iostream> #include &l ...
- 找规律 Codeforces Round #309 (Div. 2) A. Kyoya and Photobooks
题目传送门 /* 找规律,水 */ #include <cstdio> #include <iostream> #include <algorithm> #incl ...
- 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 ...
- Codeforces D. Little Elephant and Interval(思维找规律数位dp)
题目描述: Little Elephant and Interval time limit per test 2 seconds memory limit per test 256 megabytes ...
- Codeforces 193E - Fibonacci Number(打表找规律+乱搞)
Codeforces 题目传送门 & 洛谷题目传送门 蠢蠢的我竟然第一眼想套通项公式?然鹅显然 \(5\) 在 \(\bmod 10^{13}\) 意义下并没有二次剩余--我真是活回去了... ...
- 找规律 Codeforces Round #290 (Div. 2) A. Fox And Snake
题目传送门 /* 水题 找规律输出 */ #include <cstdio> #include <iostream> #include <cstring> #inc ...
随机推荐
- java批处理、MySQL批处理
e: cd MySQL\bin mysql -uroot -proot @pause MySQL批处理.bat e: cd JAVA\jdk1.8.0_77\bin javac Hello.java ...
- AJPFX详解泛型中super和extends关键字
首先,我们定义两个类,A和B,并且假设B继承自A.下面的代码中,定义了几个静态泛型方法,这几个例子随便写的,并不是特别完善,我们主要考量编译失败的问题: Java代码 public class Ge ...
- mysql 字段包含某个字符的函数
通过sql查询语句,查询某个字段中包含特定字符串: 例子:查询e_book表的types字段包含字符串"3",有下面4种方式 select * from e_book where ...
- linux下php访问sql server设置
安装freeIDS 官网下载地址: wget ftp://ftp.freetds.org/pub/freetds/stable/freetds-1.00.18.tar.gz 1.1.到下载目录解压 t ...
- 镜像中的 Everything, GnomeLive ,KdeLive ,livecd ,NetInstall的区别?
everything: 对完整版安装盘的软件进行补充,集成所有软件 GnomeLive , GNOME桌面版 KdeLive , KDE桌面版 livecd 光盘上运行的系统 ,NetInstall ...
- 内存管理总结-autoreleasePool
转自其他 序言 无论是在MRC时期还是ARC时期,做过开发的程序员都接触过autoreleasepool.尽管接触过但本人对它还不是很了解.本文只是将自己的理解说出来.在内存管理的文章中提到了OC的内 ...
- NOT IN、NOT EXISTS的相关子查询改用LEFT JOIN--sql2000性能优化
参考文章:SQL SERVER性能优化综述(很好的总结,不要错过哦) 数据库:系统数据库 子查询的用法 子查询是一个 SELECT 查询,它嵌套在 SELECT.INSERT.UPDATE.DELET ...
- MySQL_将ubuntu18.04上的数据库导出并导入windows10下
1.使用:mysqldump -uroot -p databasename>filename.sql databasename:要导出的数据库名. filename:指定导出sql文件的文件名. ...
- eureka 注册中心
1.eureka版本更新后,pom依赖名称变化 v1.2.7spring-cloud-starter-eureka-server v2.0.0spring-cloud-starter-netflix- ...
- JS的type类型为 text/template
JS标签中有时候会看见<script type="text/tmplate" >,大概就是一个放置模板的地方,而这些东西并不显示在页面 在js里面,经常需要使用js往页 ...