luogu#P10580. [蓝桥杯 2024 国 A] gcd 与 lcm

[蓝桥杯 2024 国 A] gcd 与 lcm

Problem Description

Given two numbers x,yx, y, find how many different sequences (a1,a2,,an)(a_1, a_2, \cdots, a_n) of length nn have the greatest common divisor of all elements equal to xx and the least common multiple equal to yy.

Two sequences (a1,a2,,an)(a_1, a_2, \cdots, a_n) and (b1,b2,,bn)(b_1, b_2, \cdots, b_n) are considered different if there exists at least one position ii such that aibia_i \neq b_i.

Since the answer may be very large, output the result modulo 998 244 353998\ 244\ 353.

Input Format

The first line contains an integer QQ, the number of queries.

The next QQ lines each contain three integers x,y,nx, y, n, representing one query. Adjacent integers are separated by a single space. For each query, it is guaranteed that there exists at least one sequence satisfying the conditions.

Output Format

Output QQ lines. Each line contains one integer, the answer for each query in order.

3
3 6 2
12 144 3
233 251640 10
2
72
905954656

Hint

For 40%40\% of the test cases, n30n \le 30.
For 70%70\% of the test cases, n5000n \le 5000.
For all test cases, 1Q1001 \le Q \le 100, 2n1052 \le n \le 10^5, 1x,y1091 \le x, y \le 10^9.

Translated by ChatGPT 5