HDU-2028-Lowest Common Multiple Plus
:注意两数相乘可能超出范围 导致WA
#include<iostream> using namespace std; int GCD(int a, int b) { if(b==0) return a; return GCD(b, a%b); } int main() { int n; while(cin>>n) { int a, b, c; cin>>a; for(int i=1; i<n; i++) { cin>>b; c=GCD(a, b); a=a/c*b;// a*b/c 就WA了 } cout<<a<<endl; } return 0; }