#CCBCHBON0000028. Đếm ký tự số trong luồng (Count Decimal Digits in a Stream)
Đếm ký tự số trong luồng (Count Decimal Digits in a Stream)
Count Decimal Digits in a Stream
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Read the entire text stream until EOF and count ASCII decimal digit characters 0 through 9, including 0. Ignore all other characters. An empty stream gives zero. No array is needed.
Input
A UTF-8 text stream of at most 100000 bytes, possibly empty, multi-line or without a trailing newline.
Output
Print the number of ASCII digits (0–9).
Subtasks
-
Subtask 1 (20%): UTF-8 stream length at most 20 bytes.
-
Subtask 2 (30%): UTF-8 stream length at most 500 bytes.
-
Subtask 3 (50%): UTF-8 stream length at most 100000 bytes.
Examples
Example 1
Input:
A0 23
-9 x
Output:
4
Explanation:
ASCII digits found: ['0', '2', '3', '9']. Total: 4 characters.
Example 2
Input:
no numbers
Output:
0
Explanation:
ASCII digits found: []. Total: 0 characters.
Example 3
Input:
Output:
0
Explanation:
ASCII digits found: []. Total: 0 characters.