题解 | #BC44 小乐乐与欧几里得#
小乐乐与欧几里得
https://www.nowcoder.com/practice/da13e0cf321e4df9acd0fdf0a433cbb0
#include <stdio.h> int gcd(int a, int b) { // Greatest Common Divisor return (b==0)? a: gcd(b, a%b); } long lcm(int a, int b) { // Least Common Multiple return (long)a*b/gcd(a,b); } int main() { int a, b; long c; while(scanf("%d%d", &a, &b) != EOF) { c = gcd(a, b) + lcm(a, b); printf("%ld\n", c); } return 0; }