PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#CCBCHBA0000044. Sum of Digits of a Five Digit Number (Sum of Digits of a Five Digit Number)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Sum of Digits of a Five Digit Number (Sum of Digits of a Five Digit Number)
Sum of Digits of a Five Digit Number
Source: HackerRank
Version: Phuoc Hung OJ Extended
Problem Statement
For a five-digit positive integer, add its five digits using remainder and integer division.
Input
One integer 10000<=n<=99999.
Output
The sum of the five digits.
Subtasks
- Subtask 1 (20%): 10000<=n<=19999.
- Subtask 2 (30%): 10000<=n<=59999.
- Subtask 3 (50%): 10000<=n<=99999.
Examples
Example 1
Input
10564
Output
16
Explanation
1+0+5+6+4=16.
Example 2
Input
10000
Output
1
Explanation
Trailing zeros contribute zero.