题解 | #小乐乐与欧几里得#
小乐乐与欧几里得
https://www.nowcoder.com/practice/da13e0cf321e4df9acd0fdf0a433cbb0
//超简单思路 不过这样算法效率低 #include <stdio.h> int main() { long m, n; int i, j; scanf("%ld %ld", &m, &n); if (m < n) { for (i = m; i > 0; i--) { if (m % i == 0 && n % i == 0) { printf("%ld\n", i + m * n / i); break; } } } else { for (i = n; i > 0; i--) { if (n % i == 0 && m % i == 0) { printf("%ld\n", i + m * n / i); break; } } } return 0; }