import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while (t-- > 0) {
int a = sc.nextInt();
int b = sc.nextInt();
int l = sc.nextInt();
int x = 0, ax = 0;
Set<Integer> set = new HashSet<>();
while (ax <= l) {
ax = (int) Math.pow(a, x++);
if (l % ax != 0) continue;
int y = 0, by = 0;
while (ax * by <= l) {
by = (int) Math.pow(b, y++);
if (l % (ax * by) == 0) set.add(l / (ax * by));
}
}
System.out.println(set.size());
}
}
}
codeforces-C
最新推荐文章于 2024-11-03 22:58:04 发布