#CCBCHBON0000002. Đếm số trước dấu 0 (Count Values Before Zero)
Đếm số trước dấu 0 (Count Values Before Zero)
Count Values Before Zero
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Read integer values until the first zero. Zero is the terminating sentinel and is not counted. Count how many nonzero values occur before it; if it is the first value, output 0.
Input
A whitespace-separated stream of at most 100001 integers. The final value is the first zero; preceding values are nonzero integers within . There is no leading length .
Output
Print the number of values before the first zero.
Subtasks
-
Subtask 1 (20%): At most 8 values before zero; .
-
Subtask 2 (30%): At most 1000 values before zero; .
-
Subtask 3 (50%): At most 100000 values before zero; .
Examples
Example 1
Input:
4 -2 9 0
Output:
3
Explanation:
Only values before the first zero are counted; zero terminates input.
Example 2
Input:
0
Output:
0
Explanation:
Only values before the first zero are counted; zero terminates input.