hdu 1019 最小公倍数
简单题 注意__int64 的使用
Problem : 1019 ( Least Common Multiple ) Judge Status : Accepted RunId : 10599776 Language : C++ Author : xiaoniuwin Code Render Status : Rendered By HDOJ C++ Code Render Version 0.01 Beta #include<iostream> using namespace std; __int64 f(__int64 a,__int64 b) { __int64 t; __int64 sum=a*b; if(a<b) { t=a; a=b; b=t; } while(b) { t=a%b; a=b; b=t; } return sum/a; } int main() { int t,n; __int64 x; __int64 lcm; scanf("%d",&t); while(t--) { scanf("%d",&n); scanf("%I64d",&lcm); n--; while(n--) { scanf("%I64d",&x); lcm=f(lcm,x); } printf("%I64d\n",lcm); } return 0; }