| BSUIR Open XII: Student Final |
|---|
| Finished |
The cannonball problem is to find such a number of cannonballs that they can be stacked in a single layer in the form of a square and in the form of a pyramid with a square base. It is easy to see that such a problem can be reduced to finding natural $$$n$$$ and $$$m$$$ such that:
$$$$$$\sum_{i=1}^{n}i^2 = m^2$$$$$$
It is known for sure that there are exactly two solutions: $$$n = 1$$$ and $$$m = 1$$$, that is, one cannonball, and $$$n = 24$$$ and $$$m = 70$$$, that is, $$$70^2 = 4900$$$ cannonballs.
In the era of interstellar travel, this arrangement may not be entirely convenient. For example, pirate spaceships use cannonballs arranged in the shape of a truncated pyramid consisting of exactly $$$k$$$ layers. This way we get a generalized cannonball problem, which can be reduced to finding, for a given $$$k$$$, natural numbers $$$n$$$ and $$$m$$$ such that:
$$$$$$\sum_{i=1}^{k}(n+i-1)^2 = m^2$$$$$$
To effectively combat space piracy, it was decided to study this problem. You are asked to find any solution to a problem for a given $$$k$$$. Since $$$m$$$ is uniquely determined from $$$n$$$, you are asked to find only $$$n$$$.
Figure 1. An example of stacking cannonballs in the shape of a truncated pyramid ($$$n = 3$$$, $$$k = 3$$$) The first line contains a single integer $$$t$$$ — the number of values of $$$k$$$ for which the authors want to find out the solution.
In the following $$$t$$$ lines, a single integer $$$k$$$ — is specified, a value for which at least one solution must be found.
$$$$$$1 \le t \le 10$$$$$$ $$$$$$1 \le k \le 2500 $$$$$$
For each given $$$k$$$, print "Yes" on a separate line if there is a solution, otherwise print "No". If there is a solution, then in the next line print a single positive integer $$$n$$$ — any solution to the generalized cannonball problem that does not exceed $$$10^{18}$$$.
It is guaranteed that if a solution exists, then there is a solution not exceeding $$$10^{18}$$$.
34624
No No Yes 1
1529
Yes 255
| Name |
|---|


