Possible?
Time Limit: 0.5 sec
The Problem
Let's say P= [P1, P2 . . . PN] is a permutations of all positive integers less than or equal to N. A function called "special count" F(P) is defined as:
Now Hiya gives a N and K to Diya and asks if K is a possible special count for any permutation of first N positive integers.
The Input
First line contains T(1 ≤ T ≤ 100), the number of test cases. Each test case consists of N(1 ≤ N ≤ 40) and K(0 ≤ K ≤ 2000) in one line.
The Output
For each test case, print "YES" or "NO", denoting whether K is a possible special count or not.
Sample Input
2
2 1
3 2
Sample Output
NO
YES
Explanation
First test case: None of the two permutations [1, 2] and [2, 1] have special count 1.
Second test case: Permutations [1, 3, 2] and [2, 1, 3] have special count 2.
Inter University Programming Contest - 2016 [BGC Trust University Bangladesh]
Problem Setter: Parag Paul