Description
hwf h w f 捡到了一个 n×n n × n 的白色棋盘,但他不喜欢白色,所以他准备用一堆 1×2 1 × 2 和 3×1 3 × 1 的黑色方块把棋盘盖住。
然而 hwf h w f 有很严重的强迫症,他不允许有黑色的方块重叠,而且所有 1×2 1 × 2 的必须全部垂直放置,所有 3×1 3 × 1 的必须全部平行放置。
请问 hwf h w f 能完成这个任务吗?
Input
第一行:一个整数 T T ,代表询问个数 。
接下来 T T 行:每行一个整数 (3≤n≤103) ( 3 ≤ n ≤ 10 3 ) 。
Output
共 T T 行,每行一个字母, N N 代表他不能完成任务,代表能。
Sample Input
2
3
5
Sample Output
Y
N
Solution
n n 为偶数显然的就可以铺满, n n 为奇数时还剩最后一行没有办法铺满,此时想铺满只能用的砖,即需要 3|n 3 | n ,故只要 n n 可以被或 3 3 <script type="math/tex" id="MathJax-Element-25">3</script>整除即有解,否则无解
Code
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<ctime>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int INF=0x3f3f3f3f,maxn=100001;
int main()
{
int T,n;
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
if(n%2==0||n%3==0)printf("Y\n");
else printf("N\n");
}
return 0;
}