标签:common txt print multiple comm std pen sig least
思路:最小公倍数=两个数相乘除以两个数的最大公约数。
AC代码:
#include <iostream> #include <cstdio> using namespace std; unsigned int gcd(unsigned int t1,unsigned int t2) { if(t2==0) return (t1); else return gcd(t2,t1%t2); } int main(void) { freopen("in.txt","r",stdin); unsigned int N; scanf("%ud",&N); while(N--) { unsigned int n,t1,t2; scanf("%u",&n); scanf("%u",&t1); n--; while(n--) { scanf("%u",&t2); t1=t1/gcd(t1,t2)*t2; } printf("%u\n",t1); } fclose(stdin); return 0; }
HDOJ_1019_大二写_Least Common Multiple
标签:common txt print multiple comm std pen sig least
原文地址:https://www.cnblogs.com/phaLQ/p/10036118.html