#C7847. Pyramid Bricks

    ID: 51763 Type: Default 1000ms 256MiB

Pyramid Bricks

Pyramid Bricks

You are given two integers N and K. In this problem, you need to determine if K represents the total number of bricks required to build a complete pyramid that has N rows, where the i-th row contains exactly i bricks. Recall that the total number of bricks to build a pyramid with N rows is given by the formula:

( S = \frac{N(N+1)}{2} )

Your task is to check whether ( K = S ) for the given value of N.

inputFormat

The input is read from standard input (stdin). The first line contains a single integer T, representing the number of test cases. Each of the next T lines contains two space-separated integers N and K. (N) denotes the number of rows in the pyramid and (K) represents the total number of bricks.

outputFormat

For each test case, output a single line to standard output (stdout) containing either 'YES' if K matches the total number of bricks required for a pyramid with N rows (i.e. ( K = \frac{N(N+1)}{2} )), or 'NO' otherwise.## sample

1
1 1
YES

</p>