当前位置:网站首页>872. Maximum common divisor
872. Maximum common divisor
2022-07-24 19:36:00 【acacac.】
Given n Right integer ai,bi, Please find the greatest common divisor of each logarithm .
Input format
The first line contains integers n.
Next n That's ok , Each line contains an integer pair ai,bi.
Output format
The output, n That's ok , Each line outputs the maximum common divisor of an integer pair .
Data range
1≤n≤105,
1≤ai,bi≤2×109
sample input :
2
3 6
4 6
sample output :
3
2
#include<bits/stdc++.h>
using namespace std;
int n;
int gcd(int a, int b)
{
return b ? gcd(b, a % b) : a;
}
int main()
{
cin >> n;
int a, b;
for(int i=0; i<n; i++) {
cin >> a >> b;
cout << gcd(a ,b) << endl;
}
return 0;
}
边栏推荐
猜你喜欢

Talk about your transformation test development process

How to use the interface control telerik UI for WinForms development step progress bar?

02 | 环境准备:如何在windows下安装和配置一个基本的php开发环境?

Common methods of string class
![2019 Hangdian multi school first 6581 vacation [thinking]](/img/38/5a74d3ef346d6801f9da8fd3a4b23a.png)
2019 Hangdian multi school first 6581 vacation [thinking]

MySQL1
Cmake series tutorial 2 HelloWorld

Emergency lighting design of large stadiums and gymnasiums

Tencent Browser service TBS usage

01 | 开篇词:手把手教你搭建一个博客网站
随机推荐
Analysis of the basic concept of digital warehouse
Literature reading: gopose 3D human pose estimation using WiFi
How to select software dongle
Ensure the health and safety of front-line construction personnel, and implement wrong time construction at Shenzhen construction site
【无标题】
[understanding of opportunity-48]: Guiguzi - Chapter 7 - collect information in advance, make predictions and implementation plans in advance
2019 Hangzhou Electric Multi School Game 9 6684 Rikka with game [game question]
[untitled]
MySQL (data types and integrity constraints)
[face to face experience of school recruitment] 8 real questions of pointer interview. Come and test how many you have mastered.
Thread theory knowledge
Jedi survive and eat chicken F12 screenshot save path reference
Pyhanlp installation tutorial
MySQL index principle and query optimization "suggestions collection"
Cmake series tutorial 1- initial cmake
[in depth study of 4g/5g/6g topic -39]: urllc-10 - in depth interpretation of 3GPP urllc related protocols, specifications and technical principles -3- how to distinguish urllc services? Detailed expl
Using videoview to realize video playback in turns
asp. Net coree file upload and download example
Software core data protection solution
Codeforces round 580 (Div. 2) c- almost equal [Law]