PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000223. Đếm cặp từ đẳng thức GCD–LCM (The Number of Pairs)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Đếm cặp từ đẳng thức GCD–LCM (The Number of Pairs)

The Number of Pairs

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Given positive integers c,d,xc,d,x, count ordered positive integer pairs (a,b)(a,b) satisfying

c⋅lcm⁡(a,b)−d⋅gcd⁡(a,b)=x.c\cdot\operatorname{lcm}(a,b)-d\cdot\gcd(a,b)=x.

The two orders are distinct when a≠ba\ne b. Print the exact count.

Input

One line contains c,d,xc,d,x.

Output

Print the count.

Subtasks

  • Subtask 1 (20 points): 1≤c,d,x≤1001\le c,d,x\le 100.

  • Subtask 2 (30 points): 1≤c,d,x≤1000001\le c,d,x\le 100000.

  • Subtask 3 (50 points): 1≤c,d,x≤100000001\le c,d,x\le 10000000.

Examples

Example 1

Input

1 1 3

Output

4

Explanation

The four ordered pairs are (1,4), (4,1), (3,6) and (6,3). Each satisfies the equality with result 3.

Example 2

Input

4 2 6

Output

3

Explanation

The three pairs (1,2), (2,1) and (3,3) each satisfy 4lcm⁡(a,b)−2gcd⁡(a,b)=64\operatorname{lcm}(a,b)-2\gcd(a,b)=6.