当前位置:网站首页>数学知识:最大公约数—约数
数学知识:最大公约数—约数
2022-06-21 22:27:00 【奋斗吧!骚年!】
题目:AcWing 872. 最大公约数
给定 n 对正整数 ai,bi,请你求出每对数的最大公约数。
输入格式
第一行包含整数 n。
接下来 n 行,每行包含一个整数对 ai,bi。
输出格式
输出共 n 行,每行输出一个整数对的最大公约数。
数据范围
1≤n≤105,
1≤ai,bi≤2×109
输入样例:
2
3 6
4 6
输出样例:
3
2
#include <iostream>
using namespace std;
int gcd(int a,int b)
{
return b?gcd(b,a%b):a;
}
int main()
{
int n,a,b;
cin>>n;
while(n--)
{
cin>>a>>b;
cout<<gcd(a,b)<<endl;
}
return 0;
}
边栏推荐
- AttributeError: ‘WebDriver‘ object has no attribute ‘w3c‘
- 二叉排序树
- eureka的解析
- SQL interview questions: top 15 questions in 2022
- spacy. load(“en_core_web_sm“)###OSError: [E050] Can‘t find model ‘en_core_web_sm‘.
- The minimum non composable sum of arrays
- Unity-网络开发(一)
- Cvpr2022 𞓜 loss problem in weakly supervised multi label classification
- How to modify the judgment time of the equipment in the offline state when the national standard equipment is registered on the easycvr platform?
- Flexer series: indexedstack in Flexer
猜你喜欢

Basic contents of external sorting

Neural networks and support vector machines for machine learning

Lectures explanation for unsupervised graph level representation learning (usib)

What if the word selection box is not displayed for win11 typing? Solution of not displaying word selection box in win11 typing

转载:网络加载框架 - Retrofit
![class path resource [classpath*:mapper/*.xml] cannot be opened because it does not exist](/img/1a/294eb0128285686ede415991f69be7.png)
class path resource [classpath*:mapper/*.xml] cannot be opened because it does not exist

redis主从复制(九)

Celery+rabbit distributed task processing
![Jmter test command [note]](/img/96/4290b92beb0755c6724a3b8d7dc635.png)
Jmter test command [note]

ERP is dead, the management background is cold, and seckill system is king!
随机推荐
组件传值:兄弟间传值(非父子组件进行传值)
基于Arduino框架下VSCode PlatformIO一个项目配置两种不同开发板的兼容模式
Redis master-slave replication (9)
Win11 hotspot connection successful but no network? Solution of win11 mobile hotspot and network conflict
Flag bit generation
MNIST image classification and comparison based on K-nearest neighbor
The minimum non composable sum of arrays
Six little-known SQL technologies in SQL tutorial can help you save 100 hours per month
Software project lawyer due diligence white paper - full text 19 pages, please contact the author
Component value transfer: child components transfer data to parent components
Analysis of Eureka
What if the program input point cannot be located in the dynamic link library
Celery+rabbit distributed task processing
IDA静态逆向分析工具使用详解
The ranking list of programming languages has been published in June, and this language should be "gods"
pytorch 界面编程相关
Lectures explanation for unsupervised graph level representation learning (usib)
Redis master-slave replication (9)
spacy. load(“en_core_web_sm“)###OSError: [E050] Can‘t find model ‘en_core_web_sm‘.
Npdp| how to do well in product life cycle management?