杭电ACM1019求最大公约数

最后更新于:2022-04-01 09:47:31

~~~ #include<iostream> using namespace std; int main() { int gcd(int a,int b); int n,m,a; cin>>n; while(n--) { cin>>m; cin>>a; m--; while (m--) { int b; cin>>b; int k=gcd(a,b); a=b/k*a; } cout<<a<<endl; } return 0; } int gcd(int a,int b) { int r=1; while (r>0) { r=a%b; a=b; b=r; } return a; } ~~~
';