solution.json 1.5 KB
Newer Older
每日一练社区's avatar
每日一练社区 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
{
  "type": "code_options",
  "author": "csdn.net",
  "source": "solution.md",
  "exercise_id": "9bcfaba804d84dbf9ee53401b14c70fb",
  "keywords": "算法初阶,基础知识,算法基础,设计算法,分析分治算法",
  "title": "求最大公约数和最小公倍数",
  "desc": [
    {
      "content": "\n<p>输入两个数x 和y&#xff0c;如果x 或y 小于等于0&#xff0c;提示请输入正整数&#xff0c;求这两个数的最大公约数和最小公倍数。\n注意&#xff1a;可以采用欧几里得辗转相除算法来求最大公约数。最小公倍数的计算方法是两数的乘积除以两数最大公约数的结果。</p>",
      "language": "markdown"
    }
  ],
  "answer": [
    {
      "content": "",
      "language": "python"
    }
  ],
  "prepared": [
    [
      {
        "content": "",
        "language": "python"
      }
    ],
    [
      {
        "content": "",
        "language": "python"
      }
    ],
    [
      {
        "content": "",
        "language": "python"
      }
    ]
  ],
  "template": {
    "content": "x = int(input(\"输入x:\"))\ny = int(input(\"输入y:\"))\nif x <= 0 or y <= 0:\n\tprint(\"请输入正整数\")\nif x < y:\n\tx,y=y,x\n\tv1 = x*y\n\tv2 = x%y\n\twhile v2 != 0:\n\t\tx=y\n\t\ty = v2\n\t\tv2 = x % y\n\tv1 =v1/ y\n\tprint(\"最大公约数为:%d\" % y)  \n\tprint(\"最小公倍数为:%d\" % v1) ",
    "language": "python"
  },
  "node_id": "dailycode-eb8c1b6d542e4aa6aa9b722336978115",
  "license": "csdn.net",
  "created_at": 1637894161,
  "topic_link": "https://bbs.csdn.net/topics/600469983"
}