#K53337. Sum of Multiples of 3
Sum of Multiples of 3
Sum of Multiples of 3
Given T test cases, each consisting of a list of integers, your task is to compute the sum of all elements that are divisible by 3. More formally, for a list \(A = [a_1, a_2, \dots, a_n]\), you need to compute the sum
[ S = \sum_{i=1}^{n} \left{ a_i ;:; a_i \equiv 0 ; (\bmod; 3) \right} ]
For each test case, output the computed sum on a separate line. Input will be given via standard input, and output via standard output.
inputFormat
The input begins with an integer T, denoting the number of test cases. For each test case:
- An integer n, representing the number of elements in the test case.
- A line containing n space-separated integers.
All input is provided via standard input (stdin).
outputFormat
For each test case, output a single line containing the sum of the elements that are multiples of 3. The output is printed on standard output (stdout).
## sample4
4
3 6 8 10
5
7 14 21 28 35
4
1 2 4 5
5
3 6 9 12 15
9
21
0
45
</p>