#CCBCHHAI0000002. Mật khẩu khác 0 (First Nonzero Password)
Mật khẩu khác 0 (First Nonzero Password)
First Nonzero Password
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
A device receives consecutive integer codes. Zero is invalid. The first nonzero code is accepted and input stops immediately. Count all reads, including the successful one.
Input
A whitespace-separated sequence of integers. The last value is the first nonzero code; no values follow it.
Output
Print the positive count of values read through and including the first nonzero one.
Subtasks
- Subtask 1 (20%): At most 5 values; each value has absolute value at most 10.
- Subtask 2 (30%): At most 100 values; each value has absolute value at most 1000.
- Subtask 3 (50%): At most 100001 values; each value has absolute value at most 1000000.
Examples
Example 1
Input
0 0 -7
Output
3
Explanation
Read 0 twice (counts 1 and 2), then -7 (count 3); -7 is nonzero and accepted.
Example 2
Input
8
Output
1
Explanation
The first value 8 is nonzero, so exactly one read occurs.