PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000213. Đếm ước giai thừa chia hết cho D (Divisibility of Factors)
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 giai thừa chia hết cho D (Divisibility of Factors)
Divisibility of Factors
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
Given integers and , with , count the positive integers satisfying both conditions:
- divides ;
- is divisible by .
We use . Divisibility by a negative integer has its usual meaning: divides exactly when divides . Distinct divisor values are counted separately.
Input
The only line contains the integers .
Output
Print the number of distinct positive divisors of divisible by , or 0 if there are none.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Input
10 2
Output
240
Explanation
. A divisor divisible by must have exponent of between and (eight choices). The exponents of admit choices, respectively. Thus divisors qualify.