Codeforce - 267A - Subtractions

这是一个关于编程挑战的问题,要求计算在应用辗转相除法(每次从较大数中减去较小数)后,每对数字需要进行多少次操作。输入包含一对数的数量n(1≤n≤1000),每对数都是正整数,范围在1到10^9之间。输出是每对数对应的操作次数。
摘要由CSDN通过智能技术生成

A. Subtractions
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
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 (ai, bi). How many operations will be performed for each of them?

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

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

Examples
input
2
4 17
7 987654321 <

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值