题目描述

编写一个类GCD,该类的功能是实现两个数的最大公约数,类需要有构造函数,请在main函数内通过创建类的对象来实现该功能。

输入

输入多组数据,每组数据包含两个整数

输出

输出两个数的最大公约数

样例输入

100 50
20 30

样例输出

50
10

C++

#include <bits/stdc++.h>
using namespace std;int gcd(int a,int b) {return b==0?a:gcd(b,a%b);
}int main() {int a,b;while(cin>>a>>b) {cout<<gcd(a,b)<<endl;}return 0;
}

Python

def gcd(a, b):if b == 0:return areturn gcd(b, a % b)while True:try:a, b = map(int, input().split())print(gcd(a, b))except:break

1299: Problem 1相关推荐

  1. Problem B: 立体空间中的点(II)

    Problem B: 立体空间中的点(II) Time Limit: 1 Sec   Memory Limit: 128 MB Submit: 1662   Solved: 1299 [ Submit ...

  2. linux下yum错误:[Errno 14] problem making ssl connection Trying other mirror.

    所有的base 都要取消注释 mirrorlist 加上注释 另外所有的enable都要设为零 目录 今天是要yum命令安装EPEL仓库后 yum install epel-release 突然发现y ...

  3. A + B Problem

    1001: A + B Problem Description 计算 A + B. Input 多组测试数据,每组测试数据占一行,包括2个整数. Output 在一行中输出结果. Sample Inp ...

  4. Error:(49, 1) A problem occurred evaluating project ':guideview'. Could not read script 'https://r

    出现问题如下: Error:(49, 1) A problem occurred evaluating project ':guideview'. > Could not read script ...

  5. #418 Div2 Problem B An express train to reveries (构造 || 全排列序列特性)

    题目链接:http://codeforces.com/contest/814/problem/B 题意 : 有一个给出两个含有 n 个数的序列 a 和 b, 这两个序列和(1~n)的其中一个全排列序列 ...

  6. ADPRL - 近似动态规划和强化学习 - Note 3 - Stochastic Infinite Horizon Problem

    Stochastic Infinite Horizon Problem 3.Stochastic Infinite Horizon Problem 定义3.1 无限范围的马尔可夫决策过程 (Marko ...

  7. ADPRL - 近似动态规划和强化学习 - Note 2 - Stochastic Finite Horizon Problem

    2. Stochastic Finite Horizon Problem 在这一节中主要介绍了随机DP算法来解决不确定性下的有限地范围问题,如Denition 1.4所述,它被表述为一个组合优化问题. ...

  8. There was a problem confirming the ssl certificate ……

    在安装一个Python库onetimepass时发生下面的问题: pip install onetimepass Could not fetch URL https://pypi.python.org ...

  9. HDU 1757 A Simple Math Problem

    Problem Description Lele now is thinking about a simple function f(x). If x < 10 f(x) = x. If x & ...

  10. The C10K problem原文翻译

    原文地址:http://www.cnblogs.com/fll/archive/2008/05/17/1201540.html The C10K problem 如今的web服务器需要同时处理一万个以 ...

最新文章

  1. 每30秒学会一个Python小技巧,GitHub星数4600+
  2. SQL Server 阻止了对组件 \'Ad Hoc Distributed Queries\' 的访问
  3. SpringBoot 之Quartz的使用
  4. vs2010利用属性表自动配置OpenCV(win7的64位系统,opencv版本是2.4.10)
  5. log4net环境配置
  6. 单例销毁_【PHP设计模式】单例模式
  7. arraycopy方法的作用_System. arraycopy()入门指南
  8. 操作RadGrid1,RadAjaxLoadingPanel1不出现
  9. php5.2.5 mysql_IIS6 下安裝 PHP5.2.5 和 MySQL5.0 及概念澄清
  10. 关于eclipse没有http jar的问题解释
  11. python基础教程第三版-Python基础教程(第三版)(七)再谈抽象
  12. 面向对象编程——类和实例(二)
  13. 工控行业各品牌程序扩展格式和软件
  14. 采样频率变化时,滤波器的性能会变差吗?
  15. js中math常用使用方法
  16. KMS激活报错0x8007000D
  17. Django中关于URL配置文件urls.py的理解
  18. 【问题解决】电脑微信聊天记录备份时显示不在同一网络(电脑LAN,手机WIFI)
  19. 生命探测仪能穿墙能探废墟 但不能穿透金属(图)
  20. 设计模式-----装饰模式.

热门文章

  1. 2022山东省安全员C证考试试题及答案
  2. 微型计算机结构五大,微型计算机的体系结构
  3. 从智能交通案例看物联网成功的关键
  4. 读书笔记-《墨菲定律》
  5. Android为什么图片模糊不清,Android打开图库中图片为什么从模糊变清晰
  6. 微信群二维码有效期如何延长?突破7天有效期的方法!
  7. 手眼标定算法---Sai-Lenz(A New Technique for Fully Autonomous and Efficient 3D Robotics Hand/Eye Calibrati)
  8. Qt使用flowlayout,使控件两端间距始终固定,垂直和水平间距相等
  9. Comet:基于 HTTP 长连接的“服务器推”技术
  10. torch.cat()函数用法