#CCBCHMOT0000026. Tổng chữ số (Sum of Digits)
Tổng chữ số (Sum of Digits)
Sum of Digits
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given nonnegative n, calculate the sum of its decimal digits. For example, 507 has sum 12; zero has sum zero.
Input
One integer n.
Output
Print the sum of the decimal digits.
Subtasks
- Subtask 1 (20%): 0<=n<=99.
- Subtask 2 (30%): 0<=n<=10^6.
- Subtask 3 (50%): 0<=n<=10^18.
Examples
Example 1
Input
507
Output
12
Explanation
The running total is 0 -> 7 -> 7 -> 12.
Example 2
Input
0
Output
0
Explanation
The initial sum zero is already correct.