#C7189. Perfect Pyramid Arrangement
Perfect Pyramid Arrangement
Perfect Pyramid Arrangement
You are given a number of flowers, and you need to determine whether they can form a perfect pyramid arrangement. A perfect pyramid is one in which the first level has 1 flower, the second level has 2 flowers, the third level has 3 flowers, and so on. This means that the total number of flowers must be a triangular number, i.e., it can be expressed in the form \( T_k = \frac{k(k+1)}{2} \) for some positive integer \( k \).
For each test case, if the given number of flowers \( N \) can form such an arrangement, output 1
. Otherwise, output 0
.
inputFormat
The input is read from the standard input (stdin) and is structured as follows:
- The first line contains a single integer \( T \), representing the number of test cases.
- Each of the following \( T \) lines contains a single integer \( N \), the number of flowers for that test case.
outputFormat
For each test case, output a single line to the standard output (stdout) containing a single integer: 1
if the number of flowers can form a perfect pyramid (i.e. it is a triangular number), or 0
otherwise.
3
5
6
10
0
1
1
</p>