【数学基础】【最小公倍数和最大公约数】

xiaoxiao2021-02-28  128

#include<stdio.h> #define LL long long LL gcd(LL a,LL b) { if(a%b==0) return b; else return gcd(b,a%b); } LL lcm(LL a,LL b) { return (a/gcd(a,b)*b);//如果是int,这样处理可以防止溢出 } int main() { LL n,m; while(scanf("%lld%lld",&n,&m)!=EOF) { printf("%lld\n",lcm(n,m)); } return 0; }
转载请注明原文地址: https://www.6miu.com/read-26841.html

最新回复(0)