此博客链接:https://www.cnblogs.com/ping2yingshi/p/12368569.html
Lowest Common Multiple Plus(73min)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2028
#include<stdio.h> #include<math.h> #include<stdlib.h> #include<string.h> int main() { int n; int n1; int n2; while (~scanf_s("%d",&n)) { int arr[1000]; int j = 0; int temp = 0; for (int i=0;i<n;i++)//读取数据 { scanf_s("%d", &arr[i]); } for ( j = 0; j < n - 1; j++) { n1 = arr[j]; n2 = arr[j + 1]; while (n1 % n2 != 0)//辗转相除法求最大公约数 { temp = n1 % n2; n1 = n2; n2 = temp; } arr[j + 1] = arr[j + 1] / n2 * arr[j];//求最小公倍数 } printf("%d\n", arr[j]); } return 0; }
原文:https://www.cnblogs.com/ping2yingshi/p/12368569.html