#CCBOTPBA0000012. Số lượng số khác 0 trước sentinel (Count Nonzero Values Before Sentinel)
Số lượng số khác 0 trước sentinel (Count Nonzero Values Before Sentinel)
Count Nonzero Values Before Sentinel
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Read integers in sequence. The first zero is a terminator and is not counted. Print the number of nonzero values before it. The first value may itself be zero.
Input
A sequence of 0..100000 nonzero integers followed by exactly one terminating zero, with no data after the zero.
Output
Print the count of values preceding the first zero.
Subtasks
-
Subtask 1 (20%): At most 10 preceding values, absolute values ≤ 100.
-
Subtask 2 (30%): At most 1000 preceding values, absolute values ≤ 10^6.
-
Subtask 3 (50%): At most 100000 preceding values, absolute values ≤ 10^9.
Examples
Example 1
Input:
4 -1 8 0
Output:
3
Explanation: There are three nonzero values before the first zero.
Example 2
Input:
0
Output:
0
Explanation: The initial zero immediately terminates the sequence.