#C3622. Partitioning an Integer into Distinct Positive Integers

    ID: 47070 Type: Default 1000ms 256MiB

Partitioning an Integer into Distinct Positive Integers

Partitioning an Integer into Distinct Positive Integers

You are given two integers n and k. Your task is to determine whether it is possible to partition the integer n into exactly k distinct positive integers. The necessary and sufficient condition for such a partition is that n is at least as large as the sum of the first k positive integers, i.e. $$\frac{k(k+1)}{2}$$. If this condition is satisfied, print YES; otherwise, print NO.

For example:

  • For n = 8 and k = 3, the sum of the first 3 positive integers is 6 and since 8 \ge 6 the answer is YES.
  • For n = 7 and k = 4, the sum of the first 4 positive integers is 10 and since 7 < 10 the answer is NO.

inputFormat

The first line contains an integer T — the number of test cases.

Each of the following T lines contains two space-separated integers n and k, where n is the integer to be partitioned and k is the number of distinct positive integers required.

It is guaranteed that the input is provided via standard input (stdin).

outputFormat

For each test case, output a single line with the string YES if the partition is possible, or NO otherwise. The output should be sent to standard output (stdout).

## sample
3
8 3
7 4
10 5
YES

NO NO

</p>