[Templates That Are Usually Used]Greatest Common Divisor
来源:互联网 发布:见之不若知之 编辑:程序博客网 时间:2024/06/15 20:24
#include <iostream>#include <cstdio>#include <algorithm>using namespace std;int gcd(int a, int b){ int ans; if(a < b) swap(a, b); if(b == 0) ans = a; else ans = gcd(b, a%b); return ans;}int main(){ int a, b, c; cin >> a >> b; c = gcd(a, b); cout << c << endl; return 0;}
//优化:
int gcd(int x, int y){ return y == 0 ? x : gcd(y, x%y);}
- [Templates That Are Usually Used]Greatest Common Divisor
- [Templates That Are Usually Used]Least Common Multipler
- [Templates That Are Usually Used]Header Files Include and Pre-Process(ToBeContinued)
- Greatest Greatest Common Divisor
- Greatest Greatest Common Divisor HD5207
- Greatest common divisor
- The Greatest Common Divisor
- GCD (Greatest Common Divisor)
- Solving Greatest Common Divisor
- the greatest common divisor
- 最大公约数Greatest Common Divisor
- 最大公约数(greatest common divisor)算法
- 最大公约数(Greatest Common Divisor)
- hdu5207Greatest Greatest Common Divisor+枚举
- GCD Algorithm(Greatest Common Divisor)
- SGU 499:Greatest Greatest Common Divisor
- HDU 5207 Greatest Greatest Common Divisor
- 【瞎搞】 HDU 5207 Greatest Greatest Common Divisor
- libz.so.1库文件丢失导致报错:error while loading shared libraries: libz.so.1
- Linux命令unzip详解
- 组合和聚合的区别
- 黑马程序员_JDK1.5的新特性
- oracle 10.2.0.4.1升级到10.2.0.5.6
- [Templates That Are Usually Used]Greatest Common Divisor
- 生成验证码的代码
- Tor源码分析八 -- 客户端执行流程(second_elapsed_callback函数)
- CentOS 4.8 配置 nginx 和 fastcgi 运行 django 应用
- 黑马程序员_DOM(文档对象模型)
- [Templates That Are Usually Used]Least Common Multipler
- 黑马程序员_Applet程序设计
- Html A标签中 href 和 onclick用法、区别、优先级别
- 专访:前新浪网架构师徐佳转行卖水果背后的故事