1.介绍

gcd全称 :greatest common divisor

使用 __gcd( int x1, int x2 ) 函数可以高效、迅速得到x1, x2两个数的最大公因数。省去手写底层代码,专注代码逻辑的研究

2.注意

__gcd( int x1, int x2 ) 前面是两个下划线

3.头文件及命名空间

#include<algorithm>
using namespace std;

4.示例

#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
cout<<__gcd(a,b);
return 0;
}
//输入:
//288 540
//输出:
//36

5.优化

#include<iostream>
#include<algorithm>
using namespace std;
inline int gcd(int a,int b) {
return __gcd(a,b);
}
int main(){
int a,b;
cin>>a>>b;
cout<<__gcd(a,b);
return 0;
}
//输入:
//288 540
//输出:
//36
//inline()修饰功能简单的函数能提高时间效率

最新文章

  1. 安全防范:nginx下git引发的隐私泄露问题
  2. js zTree的用法
  3. iosTest
  4. android 欢迎界面的淡入效果
  5. HBuilder使用感受
  6. Python代码分析工具之dis模块
  7. [string]Roman to Integer,Integer to Roman
  8. ubuntu 设置网卡为混杂模式 以及网络配置命令
  9. Eclipse使用技巧总结(二)
  10. centos 把网卡名称修改为 eth0
  11. 【Conclusion】MySQL使用
  12. Regularity criteria for NSE 5: $u_3,\om_3$
  13. HTTP lab01 做一个简单的测试用 web页面
  14. 基于IP的docker private registry 私有仓库的搭建
  15. Vue.directive自定义指令
  16. ERROR: APK path is not specified for
  17. mybatis 中文做参数报错
  18. fis3-postpackager-loader
  19. 关闭Delphi的RTTI
  20. C#学习笔记(27)——委托排序(1)

热门文章

  1. Cesium用wsad进行场景漫游(九)
  2. ABP微服务系列学习-搭建自己的微服务结构(四)
  3. C语言多维数组的实现与操作
  4. Docker 安装mysql8
  5. js控制关闭layui的switch开关
  6. Linux命令使用时路径存在空格、特殊符号
  7. Android 缩小动画
  8. JDBC:实现Java与数据库的连接
  9. Windows.h 文件学习
  10. flask 项目构建