#K5886. Count Successful Free Throws
Count Successful Free Throws
Count Successful Free Throws
You are given a series of test cases. Each test case consists of an integer N followed by N integers that represent the outcomes of free throw attempts. Each integer is either 0 (miss) or 1 (successful). Your task is to compute the number of successful free throws for each test case and print the results in one line separated by a single space.
The input begins with an integer T representing the number of test cases. Then, for each test case, the first line contains an integer N and the following line contains N space-separated integers referring to the results of each free throw.
Mathematically, if for a test case, the outcomes are given as \(a_1, a_2, \dots, a_N\), you need to calculate the sum:
[ \text{Result} = \sum_{i=1}^{N} a_i ]
and print the result for each test case.
inputFormat
The input is provided via standard input (stdin) and it is structured as follows:
- The first line contains an integer T indicating the number of test cases.
- For each test case:
- The first line contains an integer N, the number of free throw attempts.
- The second line contains N space-separated integers (either 0 or 1) representing the outcome of each free throw.
Example:
3 5 1 0 1 1 0 4 1 1 1 1 6 0 0 0 0 0 0
outputFormat
For each test case, print the number of successful free throws on a single line (if there is more than one test case, print the results in one line separated by a single space) to standard output (stdout).
Example Output:
3 4 0## sample
1
5
1 0 1 1 0
3