题目:链接

思路:

多画出几个情况就可以找出规律来了

Knight (当大于2的时候只要两种颜色相间出现就可以了)

Gym - 101670C Chessboard Dancing(CTU Open Contest 2017 找规律)-LMLPHPGym - 101670C Chessboard Dancing(CTU Open Contest 2017 找规律)-LMLPHPGym - 101670C Chessboard Dancing(CTU Open Contest 2017 找规律)-LMLPHP

King(当大于等于3的时候,总可以用四种形式来补色,具体如下)

Gym - 101670C Chessboard Dancing(CTU Open Contest 2017 找规律)-LMLPHPGym - 101670C Chessboard Dancing(CTU Open Contest 2017 找规律)-LMLPHPGym - 101670C Chessboard Dancing(CTU Open Contest 2017 找规律)-LMLPHP

 Bishop(斜率为一的斜着的一行要不能相同,那只能是一列一个颜色了)

Gym - 101670C Chessboard Dancing(CTU Open Contest 2017 找规律)-LMLPHPGym - 101670C Chessboard Dancing(CTU Open Contest 2017 找规律)-LMLPHPGym - 101670C Chessboard Dancing(CTU Open Contest 2017 找规律)-LMLPHP

Rook(要想水平竖直的颜色不一样,那只能是斜着的一行的颜色是一样的)

Gym - 101670C Chessboard Dancing(CTU Open Contest 2017 找规律)-LMLPHPGym - 101670C Chessboard Dancing(CTU Open Contest 2017 找规律)-LMLPHPGym - 101670C Chessboard Dancing(CTU Open Contest 2017 找规律)-LMLPHP

代码:

#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn = 1e3+; int main() {
int temp;
char op;
while(scanf("%d %c",&temp,&op)!=EOF) {
if(temp==) {
printf("1\n");
continue;
} else {
if(op=='N') {
if(temp==)
printf("1\n");
else
printf("2\n");
}
else if(op=='K'){
printf("4\n");
}
else if(op=='B' || op=='R'){
printf("%d\n",temp);
}
}
}
return ;
}
/*
PutIn:
2 N
8 R
2 B
1 K
PutOut:
1
8
2
1
*/
05-19 21:50