PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000204. Chữ số cuối khác 0 của BCNN từ 1 đến N (LCM)
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ố cuối khác 0 của BCNN từ 1 đến N (LCM)
Chữ số cuối khác 0 của BCNN từ 1 đến N (LCM)
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
Let . Determine the last nonzero decimal digit of , without constructing this very large integer. For instance, has last nonzero digit .
Input
A single positive integer .
Output
Print one digit from to .
Subtasks
-
Subtask 1 (20 points): .
-
Subtask 2 (30 points): .
-
Subtask 3 (50 points): .
Examples
Example 1
Input
3
Output
6
Explanation
LCM(1,2,3)=6.
Example 2
Input
5
Output
6
Explanation
LCM(1,...,5)=60; its last nonzero digit is 6.
Example 3
Input
10
Output
2
Explanation
LCM(1,...,10)=2520; its last nonzero digit is 2.