当前位置:网站首页>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;
}
边栏推荐
猜你喜欢

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

day 2

Hucang integrated release of full data value, sequoiadb V5.2 online conference heavy attack

Clion configuring WSL tool chain

Implement a proxy pool from 0
![[German flavor] safety: how to provide more protection for pedestrians](/img/7c/12e60cc00ccfd0842be2bf404e9c5a.jpg)
[German flavor] safety: how to provide more protection for pedestrians

Reading notes of XXL job source code

Summary of articles in 2020

Pay close attention! List of the latest agenda of 2022 open atom open source Summit
![Detailed explanation of DHCP distribution address of routing / layer 3 switch [Huawei ENSP]](/img/77/28e8f826c7ee93fedada405c70b82b.png)
Detailed explanation of DHCP distribution address of routing / layer 3 switch [Huawei ENSP]
随机推荐
JS part
MySQL8.0学习记录20 - Trigger
Pure C implementation -------- Nicolas theorem
MySQL version 5.7.9 SQL_ mode=only_ full_ group_ By question
Feature extraction tool transformer Bert
Hucang integrated release of full data value, sequoiadb V5.2 online conference heavy attack
Unity code imports packages through package manager
Zooinspector Download
Convolutional neural network CNN
【JVM学习04】JMM内存模型
Flink window & time principle
Process pool and fallback function [easy to understand]
Common methods of string class
Installation and use of lsky Pro lancong drawing bed: a drawing bed program for online uploading and managing pictures
Interface component devaxpress asp Net v22.1 - new office 365 dark theme
Hidden Markov model HMM
PostgreSQL Elementary / intermediate / advanced certification examination (7.16) passed the candidates' publicity
Arrays
从服务器批量下载文件到本地
聊下自己转型测试开发的历程