问题 D: Cirno's Perfect Equation Class

内存限制:128 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:4 通过:4

题目描述

Ran is a puzzle lover and loves solving all kinds of math puzzles. One day, Cirno gives her an easy equation: ka+b=cka+b=cka+b=c.
Cirno gives the value of kkk, ccc and nnn, and want to know how many positive integer pairs (a,b)(a,b)(a,b) satisfy ka+b=cka+b=cka+b=c, b∣cb|cbc (that means c=xbc=xbc=xb, x≥1x\ge1x1 and xxx is an integer) and gcd⁡(a,b)≥n\gcd(a,b)\ge ngcd(a,b)n.
Cirno will ask qqq questions (that means there'll be qqq data cases). Help Ran answer them!

输入格式

The first line contains on integer qqq (1≤q≤1001\le q\le 1001q100), means the number of test cases.
For the next qqq lines, each line contains three integers k,c,nk,c,nk,c,n (1≤k,c,n≤1091\le k,c,n\le 10^91k,c,n109).

输出格式

For each question, output a single integer representing the number of pairs (a,b)(a,b)(a,b) satisfying all restrictions.

输入样例 复制

3
4 30 2
5 30 1
3 28 6

输出样例 复制

2
3
1