No.8100 Opening Ceremony
タグ : / 解いたユーザー数 40
作問者 :
Problem Statement
April has finally begun, and today is the day of the opening ceremony of the new term.
A class at yukicoder Elementary School has $N$ students. The $i$-th student $(1 \leq i \leq N)$ studied during spring break if $f_i = 1$, and did not study during spring break if $f_i = 0$.
You are the teacher and must report how many students in the class studied during spring break. Write a program to do this.
Input
$1$ input file consists of $T$ test cases. Overall, the input is given from standard input in the following format.$T$ ($1$ 個目のテストケースに対する入力) ($2$ 個目のテストケースに対する入力) $\vdots$ ($T$ 個目のテストケースに対する入力)The input for each test case is given in the following format.
$N$ $f_1$ $f_2$ $\cdots$ $f_N$
Output
Output $T$ lines. On the $j$-th line $(1 \leq j \leq T)$, output an integer between $0$ and $N$, inclusive, representing the number of students in the class who studied during spring break, for the $j$-th test case. Also, print a newline at the end.
Constraints
All input data satisfy the following constraints.
- $1 \leq T \leq 2000$
- $1 \leq N \leq 60$
- $f_i \ (1 \leq i \leq N)$ is $0$ or $1$
- All input values are integers
Sample
Sample 1
Input
1 5 1 0 0 1 1
Output
3
This sample input consists of $1$ test case.
Since $N = 5, (f_1, f_2, f_3, f_4, f_5) = (1, 0, 0, 1, 1)$, students $1, 4, 5$ studied during spring break, and students $2, 3$ did not study during spring break. Therefore, $3$ students studied during spring break.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。