PROBLEM LINK:
Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4
Author: notsoloud
Tester: apoorv_me
Editorialist: iceknight1093
DIFFICULTY:
566
PREREQUISITES:
None
PROBLEM:
Chef has a circular pizza, along which he can only make diametrical cuts.
Can he cut it into N pieces?
EXPLANATION:
If Chef makes no cuts, there’s one piece; so for N = 1 the answer is Yes
.
If Chef makes k\gt 0 cuts, there’ll be exactly 2k pieces, since each cut (after the first) will pass through exactly two existing pieces and divide them into two pieces each (hence creating 2 new pieces).
This means that any even number of pieces can be created; while odd numbers other than 1 can’t be created.
So, if N \gt 1, the answer is Yes
if N is even and No
otherwise.
TIME COMPLEXITY
\mathcal{O}(1) per testcase.
CODE:
Editorialist's code (Python)
for _ in range(int(input())):
n = int(input())
print('Yes' if n == 1 or n%2 == 0 else 'No')