-->
当前位置:首页 > 题库

PROGRAMMING:Is it a multiple of 3

Luz5年前 (2021-05-10)题库497
How to judge whether a number is a multiple of 3?
In addition to directly dividing by 3, we can also sum the numbers on each digit. If the sum is a multiple of 3, then the positive integer must be a multiple of 3.
For example, 654321: 6 + 5 + 4 + 3 + 2 + 1 = 21. 21 is a multiple of 3, so 654321 is a multiple of 3.
Another example is 4321:4 + 3 + 2 + 1 = 10. 10 is not a multiple of 3, so 4321 is not a multiple of 3.
The requirement of this problem is to give you $$n $$positive integers to judge whether they are multiples of 3.
For each positive integer: if it is a multiple of 3, output yes; otherwise, output No.
###Input format
The first line of input contains a positive integer n, which represents the number of positive integers.
In the following N lines, each line has a positive integer a, which represents the number to be judged.
Input to ensure that the number of digits a does not exceed 1000 and N does not exceed 55
###Output format
Output a total of N lines, each line outputs a yes or no, indicating whether the ith number is a multiple of 3.
Note: the output of each line can only be yes or no, pay attention to the case, do not have extra other characters (including spaces).
###Input example:
Here is a set of inputs. For example:
```in
three
thirteen
one hundred and twenty
two hundred and twenty-eight
```
###Output example:
The corresponding output is given here. For example:
```out
No
Yes
Yes
```







answer:If there is no answer, please comment