#C3848. Sum of Consecutive Integers

    ID: 47320 Type: Default 1000ms 256MiB

Sum of Consecutive Integers

Sum of Consecutive Integers

Problem Description:

Given a positive integer (n), determine whether it can be expressed as the sum of two or more consecutive positive integers. Formally, you are to determine if there exist integers (k \ge 2) and (a \ge 1) such that [ n = a + (a+1) + \cdots + (a+k-1) = k,a + \frac{k(k-1)}{2}, ] where (a) is the first term of the sequence and (k) is the number of consecutive terms. Output YES if such a representation exists and NO otherwise.

inputFormat

The input is read from standard input (stdin). The first line contains a single integer (T) (the number of test cases). Each of the next (T) lines contains an integer (n), where (1 \le n \le 10^9).

outputFormat

For each test case, output a single line on standard output (stdout) containing YES if (n) can be represented as the sum of two or more consecutive positive integers; otherwise, output NO.## sample

3
9
15
8
YES

YES NO

</p>