New core and magic count

0

0 votes
Easy-Medium
Problem

SBG Core elections just got over at DA-IICT and the present core decides to test the skills of the new core so the pose the following question to them{ the new core just won an election and they are in the mood to party so your task is helping them by finding the correct output.}:

Let's say P is a permutation of all positive integers less than or equal to N.Thus, P can be represented as P=[X1,X2,...,XN]. A function called "magic count" F(P) is defined as the sum of all |Xi - i| where i runs from 1 to N.

img

Xi denotes ith number in P.

Now the present core gives an N and K pair to the new core and asks if K is a possible magic count for any permutation of first N positive integers.

Input
First line contains T, the number of test cases. Each test case consists of N and K in one line.

Output
For each test case, print "YES" or "NO", denoting whether K is a possible magic count or not.

Constraints
1 ≤ T ≤ 100
1 ≤ N ≤ 50
1 ≤ K ≤ 2000

Author : Jinesh Shah

Time Limit: 5
Memory Limit: 256
Source Limit:
Explanation

First test case: Permutations [1, 3, 2] and [2, 1, 3] have magic count 2.

Second test case: None of the two permutations [1, 2] and [2, 1] have magic count 1.

Editor Image

?