PROBLEM LINK:
Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4
Authors: krypto_ray
Testers: iceknight1093, tabr
Editorialist: iceknight1093
DIFFICULTY:
TBD
PREREQUISITES:
None
PROBLEM:
Chef has three friends and N candies. Can he distribute all the candies equally to them?
EXPLANATION:
Since each candy should be distributed, and each friend should receive an equal number, the total number of candies should be divisible by 3.
So, the answer is “Yes” if N is divisible by 3, and “No” otherwise.
In most programming languages, this can be checked using the statement if (N%3 == 0)
TIME COMPLEXITY
\mathcal{O}(1) per test case.
CODE:
Editorialist's code (Python)
for _ in range(int(input())):
n = int(input())
print('Yes' if n%3 == 0 else 'No')