PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000182. Chia hoặc trừ (Division or Subtraction)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Chia hoặc trừ (Division or Subtraction)
Division or Subtraction
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
Given a positive integer , choose an integer with . Initially . While , if is divisible by , replace with ; otherwise replace it with . Count the choices of for which the final value of is exactly .
Input
The input contains .
Output
Print the number of valid values .
Subtasks
-
Subtask 1 (20 points): .
-
Subtask 2 (30 points): .
-
Subtask 3 (50 points): .
Examples
Example 1
Input
6
Output
3
Explanation
The valid choices are . The sequences of values are , , and , respectively.
Example 2
Input
3141
Output
13
Explanation
Thirteen choices of terminate at ; it is sufficient to test the divisors of and .
Example 3
Input
314159265358
Output
9
Explanation
For this large input, exactly nine valid divisors/candidates lead to the final value .