Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cstdio>
- //#include<cstdlib>
- #include<algorithm>
- using namespace std;
- int n, a, b, tab[1000];
- int NWD(int a, int b){
- while((a!=0) || (b!=0)){
- if(a>b)
- a=a%b;
- else
- b=b%a;
- }
- return max(a,b);
- }
- int NWW(int a,int b){
- a*=b/NWD(a,b);
- return a;
- }
- int main()
- {
- cin >> n;
- for (int i=0; i<n; i++){
- cin >> a;
- for(int j=0; j<a; j++)
- cin >> tab[j];
- b=NWW(tab[0],tab[1]);
- cout << b << endl;
- cout << tab[0] << endl;
- cout << tab[1] << endl;
- for (int j=2; j<a; j++)
- b=NWW(b,tab[j]);
- cout << b << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement