编程介的小学生 2017-10-28 14:34 采纳率: 20.5%
浏览 949
已采纳

Revenge of ex-Euclid

Problem Description
In arithmetic and computer programming, the extended Euclidean algorithm is an extension to the Euclidean algorithm, which computes, besides the greatest common divisor of integers a and b, the coefficients of Bézout's identity, that is integers x and y such that ax + by = gcd(a, b).
---Wikipedia

Today, ex-Euclid takes revenge on you. You need to calculate how many distinct positive pairs of (x, y) such as ax + by = c for given a, b and c.

Input
The first line contains a single integer T, indicating the number of test cases.

Each test case only contains three integers a, b and c.

[Technical Specification]
1. 1 <= T <= 100
2. 1 <= a, b, c <= 1 000 000

Output
For each test case, output the number of valid pairs.

Sample Input
2
1 2 3
1 1 4

Sample Output
1
3

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-11-17 15:45
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制