Description
hwfhwf捡到了一个n×nn×n的白色棋盘,但他不喜欢白色,所以他准备用一堆1×21×2和3×13×1的黑色方块把棋盘盖住。
然而hwfhwf有很严重的强迫症,他不允许有黑色的方块重叠,而且所有1×21×2的必须全部垂直放置,所有 3×13×1的必须全部平行放置。
请问hwfhwf能完成这个任务吗?
Input
第一行:一个整数TT,代表询问个数 。
接下来TT行:每行一个整数 (3≤n≤103)(3≤n≤103)。
Output
共TT行,每行一个字母,NN代表他不能完成任务,代表能。
Sample Input
2
3
5
Sample Output
Y
N
Solution
nn为偶数显然的就可以铺满,nn为奇数时还剩最后一行没有办法铺满,此时想铺满只能用的砖,即需要3|n3|n,故只要nn可以被或33整除即有解,否则无解
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;
}