PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000202. Tìm giai thừa có đúng số chữ số 0 cuối (Trailing Zeroes (III))
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Tìm giai thừa có đúng số chữ số 0 cuối (Trailing Zeroes (III))
Tìm giai thừa có đúng số chữ số 0 cuối (Trailing Zeroes (III))
Source: LightOJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given , find the smallest nonnegative integer for which ends with exactly trailing zeros in decimal notation. Print impossible (lowercase) if such does not exist.
Input
A single integer .
Output
Print the minimum or impossible.
Subtasks
-
Subtask 1 (20 points): .
-
Subtask 2 (30 points): .
-
Subtask 3 (50 points): .
Examples
Example 1
Input
1
Output
5
Explanation
5!=120 has one trailing zero; smaller factorials have none.
Example 2
Input
2
Output
10
Explanation
10! has two factors of five and is the smallest factorial with two trailing zeros.
Example 3
Input
5
Output
impossible
Explanation
The zero count jumps from 4 at 24! to 6 at 25!, skipping 5.