题库练习 Turtle Fingers: Count the Values of k
← 上一题 下一题 →

A11299 | Turtle Fingers: Count the Values of k

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

You are given three positive integers $a$ , $b$ and $l$ ( $a,b,l>0$ ).

It can be shown that there always exists a way to choose non-negative (i.e. $\ge 0$ ) integers $k$ , $x$ , and $y$ such that $l = k \cdot a^x \cdot b^y$ .

Your task is to find the number of distinct possible values of $k$ across all such ways.

输入格式

The first line contains the integer $t$ ( $1 \le t \le 10^4$ ) — the number of test cases.

The following $t$ lines contain three integers, $a$ , $b$ and $l$ ( $2 \le a, b \le 100$ , $1 \le l \le 10^6$ ) — description of a test case.

输出格式

Output $t$ lines, with the $i$ -th ( $1 \le i \le t$ ) line containing an integer, the answer to the $i$ -th test case.

输入输出样例

输入 #1
11
2 5 20
2 5 21
4 6 48
2 3 72
3 5 75
2 2 1024
3 7 83349
100 100 1000000
7 3 2
2 6 6
17 3 632043
输出 #1
6
1
5
12
6
11
24
4
1
3
24
C++ 编辑器
输入
输出