PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000177. Đếm cơ số làm xuất hiện chữ số 0 tận cùng (Trailing Zeroes (I))
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Đếm cơ số làm xuất hiện chữ số 0 tận cùng (Trailing Zeroes (I))
Trailing Zeroes (I)
Source: LightOJ
Version: Phuoc Hung OJ Extended
Problem Statement
A positive integer can be written in different bases. For instance, , so both base and base yield a representation that ends in zero.
You may choose any integer base . A base is valid when the last digit of in that base is ; only one trailing zero is required.
Count all valid bases. Even though there is no upper bound on the base, the answer is finite.
Input
One line containing a positive integer .
Output
Print the number of integer bases for which ends in digit .
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Example 1
Input
9
Output
2
Explanation
The valid bases are and : . No other integer base is valid.
Example 2
Input
1
Output
0
Explanation
The integer has last digit in every base , so the answer is .