#K60287. Door Verification Based on ASCII Value Sum Divisibility
Door Verification Based on ASCII Value Sum Divisibility
Door Verification Based on ASCII Value Sum Divisibility
You are given a list of strings. Your task is to determine whether the sum of the ASCII values of the characters in each string is divisible by 3. If it is, output YES
; otherwise, output NO
. Note that the sum of an empty string is 0, which is divisible by 3.
The input will consist of multiple test cases. The first line contains an integer T denoting the number of test cases, followed by T lines, each containing a single string. For each test case, print the answer on a new line.
Formula: For a given string s, calculate \[ S = \sum_{i=1}^{|s|} \operatorname{ord}(s_i), \] then check if \(S \equiv 0 \pmod{3}\).
inputFormat
The first line contains an integer T -- the number of test cases. Each of the following T lines contains a string s.
outputFormat
For each test case, output a single line containing YES
if the sum of ASCII values of the characters in the string is divisible by 3; otherwise, output NO
.
2
Sherlock
Watson
NO
YES
</p>