PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000214. Chữ số khác 0 cuối cùng của chỉnh hợp (The Last Non-zero Digit)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Chữ số khác 0 cuối cùng của chỉnh hợp (The Last Non-zero Digit)
The Last Non-zero Digit
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
For integers with , the number of ordered selections of distinct objects from objects is
When , this empty product equals .
Find the last nonzero decimal digit of , obtained by removing all trailing zero digits and taking the remaining units digit.
Input
The only line contains the integers .
Output
Print exactly one digit from 1 through 9.
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Input
10 5
Output
4
Explanation
The required product is . Removing the trailing zero yields , whose units digit is . Therefore print 4.