B. Robin Hood and the Major Oak

time limit per test

1 second

memory limit per test

256 megabytes

In Sherwood, the trees are our shelter, and we are all children of the forest.

The Major Oak in Sherwood is known for its majestic foliage, which provided shelter to Robin Hood and his band of merry men and women.

The Major Oak grows iiii new leaves in the ii-th year. It starts with 11 leaf in year 11.

Leaves last for kk years on the tree. In other words, leaves grown in year ii last between years ii and i+k−1i+k−1 inclusive.

Robin considers even numbers lucky. Help Robin determine whether the Major Oak will have an even number of leaves in year nn.

Input

The first line of the input contains a single integer tt (1≤t≤1041≤t≤104) --- the number of test cases.

Each test case consists of two integers nn, kk (1≤n≤1091≤n≤109, 1≤k≤n1≤k≤n) --- the requested year and the number of years during which the leaves remain.

Output

For each test case, output one line, "YES" if in year nn the Major Oak will have an even number of leaves and "NO" otherwise.

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

Example

Input

Copy

复制代码

5

1 1

2 1

2 2

3 2

4 4

Output

Copy

复制代码
NO
YES
NO
NO
YES

Note

In the first test case, there is only 11 leaf.

In the second test case, k=1k=1, so in the 22-nd year there will be 22=422=4 leaves.

In the third test case, k=2k=2, so in the 22-nd year there will be 1+22=51+22=5 leaves.

In the fourth test case, k=2k=2, so in the 33-rd year there will be 22+33=4+27=3122+33=4+27=31 leaves.

解题说明:此题是一道数学题,每年能生成i^i个树叶,每个树叶能存活k年,求最后的数量是否是偶数。找规律能发现此题为找出以n结尾的连续整数k的和是否为偶数。

cpp 复制代码
#include<iostream>
#include<cmath>
using namespace std;

void solve()
{
	int n, k;
	cin >> n >> k;
	if (n % 2 == 0)
	{
		if (k / 2 % 2 == 0)
		{
			cout << "YES" << '\n';
			return;
		}
		else 
		{
			cout << "NO" << '\n';
			return;
		}
	}
	else
	{
		if ((k / 2 + (k % 2 != 0)) % 2 == 0)
		{
			cout << "YES" << '\n';
			return;
		}
		else
		{
			cout << "NO" << '\n';
			return;
		}
	}
}

int main() 
{
	int t = 1;
	cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}
相关推荐
白杨尚青5 分钟前
C++入门篇(十):string(上)——认识string:构造与三大遍历(一条龙讲透operator[]、迭代器、auto、范围for)
java·开发语言·c++·笔记·stl
FlightYe8 分钟前
视界原理之2D视频(二):视频文件里有什么
android·linux·网络·c++·ffmpeg·音视频·aac
可乐鸡翅yeah_10 分钟前
hls.js 切换多个视频源,新手开发常见踩坑
开发语言·前端·javascript·ios·ffmpeg·音视频·safari
Tanshu_API君13 分钟前
API 聚合平台选型指南:从参数拆解到生产落地的十个评估维度
开发语言·api
Chen—LSN14 分钟前
C语言——⽂件操作(1)
c语言·开发语言·c++·经验分享·笔记·算法·链表
狗凯之家源码网17 分钟前
PHP 开源 IM 即时通讯系统效果实测与功能展示
开发语言·开源·php
anew___18 分钟前
《从零手写操作系统 (11):文件系统初探——initrd与VFS抽象层》
java·javascript·算法
辛苦才能34 分钟前
C++ map/set 深度解析:从关联式容器的本质到 operator[] 的三重身份
开发语言·c++
Chen—LSN1 小时前
C语言——文件操作(2)
c语言·开发语言·c++·经验分享·笔记·算法·c#
纪念 2291 小时前
C++类和对象(最终篇)
开发语言·c++