codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

1515B.md (1479B)


      1 Source: https://codeforces.com/problemset/problem/1515/B
      2 
      3 B. Phoenix and Puzzle
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 Phoenix is playing with a new puzzle, which consists of $n$ identical puzzle pieces. Each puzzle piece is a right isosceles triangle as shown below.
     22 
     23  ![](https://espresso.codeforces.com/c6cceedba3e2ee14f363f5914ee59dadbb654727.png) A puzzle piece 
     24 
     25 The goal of the puzzle is to create a square using the $n$ pieces. He is allowed to rotate and move the pieces around, but none of them can overlap and all $n$ pieces must be used (of course, the square shouldn't contain any holes as well). Can he do it?
     26 
     27 Input
     28 
     29 The input consists of multiple test cases. The first line contains an integer $t$ ($1 \le t \le 10^4$) — the number of test cases.
     30 
     31 The first line of each test case contains an integer $n$ ($1 \le n \le 10^9$) — the number of puzzle pieces.
     32 
     33 Output
     34 
     35 For each test case, if Phoenix can create a square with the $n$ puzzle pieces, print YES. Otherwise, print NO.
     36 
     37 Example
     38 
     39 Input
     40 
     41 ```
     42 3
     43 2
     44 4
     45 6
     46 ```
     47 
     48 Output
     49 
     50 ```
     51 YES
     52 YES
     53 NO
     54 ```
     55 
     56 Note
     57 
     58 For $n=2$, Phoenix can create a square like this:
     59 
     60  ![](https://espresso.codeforces.com/0b74e24a22d1242f147a8b3075eeaa64effbd8bc.png) 
     61 
     62 For $n=4$, Phoenix can create a square like this:
     63 
     64  ![](https://espresso.codeforces.com/575a41e78b88b392a36dc58ec7f6d6f2cf3ce91c.png) 
     65 
     66 For $n=6$, it is impossible for Phoenix to create a square.