問題一覧 > ネタ問題

No.8100 Opening Ceremony

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (AC するまで非表示) / 解いたユーザー数 40
作問者 : square1001
お気に入りにしたユーザー ProblemId : 9453 / 自分の提出
問題文最終更新日: 2023-03-31 21:09:11
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder April Fool Contest 2023 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。