#CCBCHMOT0000033. Chữ số tận cùng khác 0 (Last Nonzero Decimal Digit)
Chữ số tận cùng khác 0 (Last Nonzero Decimal Digit)
Last Nonzero Decimal Digit
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given nonnegative n, delete all trailing zero digits from its decimal representation and print the final digit of the remaining number. If n=0, print 0. Internal zero digits are not removed.
Input
One nonnegative integer n.
Output
Print one digit from 0 through 9.
Subtasks
- Subtask 1 (20%): .
- Subtask 2 (30%): .
- Subtask 3 (50%): .
Examples
Example 1
Input
1200300
Output
3
Explanation
Removing two trailing zeros leaves 12003, whose last digit is 3.
Example 2
Input
0
Output
0
Explanation
The special case zero has answer zero.