CF267A.Subtractions

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You've got two numbers. As long as they are both larger than zero, they go through the same operation: subtract the lesser number from the larger one. If they equal substract one number from the another. For example, one operation transforms pair (4,17) to pair (4,13), it transforms (5,5) to (0,5).

You've got some number of pairs (a__i, b__i). How many operations will be performed for each of them?

你有两个数。只要它们都大于零,就对它们执行相同的操作:用较大的数减去较小的数。如果两数相等,则用其中一个数减去另一个数。例如,一次操作将数对 (4,17)(4,17) 变为 (4,13)(4,13),将 (5,5)(5,5) 变为 (0,5)(0,5)。

你有若干个数对 (ai, bi)(a_i,\,b_i)。对每个数对,总共会执行多少次操作?

输入格式

The first line contains the number of pairs n (1  ≤  n  ≤  1000). Then follow n lines, each line contains a pair of positive integers a__i, b__i (1  ≤  a__i,  b__i  ≤  109).

第一行包含数对的数量 nn(1≤n≤10001 \le n \le 1000)。接下来有 nn 行,每行包含一对正整数 ai, bia_i,\,b_i(1≤ai, bi≤1091 \le a_i,\,b_i \le 10^9)。

输出格式

Print the sought number of operations for each pair on a single line.

对每一对,输出所求的操作次数,每行一个。

输入输出样例

  • 输入#1

    2
    4 17
    7 987654321

    输出#1

    8
    141093479

输入解题思路,AI测评打分。不知道怎么写?

首页