题目描述

编写一个类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. axure怎么做5秒倒计时_如何用Axure做倒计时,由分到秒?
  2. 使用条件卷积进行实例和全景分割
  3. 宏基因组分析实战教程1. 背景知识
  4. linux 权限 x 表示,在Linux系统中,用户对目录拥有“x”权限,表示可以执行下列哪种操作?...
  5. 掌握shell应用,Linux任你行走
  6. 凌轩:中国电信在校园市场的困与囧
  7. python爬虫小说代码示例-Python从零开始写爬虫-4 解析HTML获取小说正文
  8. 常见索引结构—B-树
  9. java gsm短信发送_GSM java短信二次开发出现问题
  10. vue 对象继承_JS面向对象—对象的继承
  11. TensorFlow demo 及 tutorials
  12. tp3.2 批量插入
  13. SAS计算IV代码分享
  14. 腾讯大厂2022校招来啦
  15. 电影文件的合并与分割
  16. h2支持mysql函数,H2数据库用户自定义函数方法及范例
  17. 水管工游戏(随机地图版)
  18. 对话加拿大工程院于非院士:寻找 AI 领域的「香农定理」
  19. Golang http server 跨域问题与解决办法
  20. ele ui 清空选项和重新校验

热门文章

  1. APICloud 上传文件到云数据库2.0的代码实现
  2. 学习笔记-状态方程精确离散化
  3. 如何查询出指定地点对应的经纬度(高德地图)
  4. 鸿蒙分布式内核,鸿蒙系统:微内核,分布式
  5. Elasticsearch入门----terms聚合实现搜索热词统计
  6. AcWing 4487. 最长连续子序列 单调栈上二分 数组模拟栈的好处
  7. Content not from webpack is served from ‘/Users/xxxx/xxxx/xxxx/xxxx/public‘ directory
  8. 谈谈Fragment的用法之Fragment实现Tab切换中的那些事
  9. Python3 async def和@asyncio.coroutine的区别
  10. 极值点、驻点、拐点的区别-----专升本