Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
495 B
2
Indexable
Never
//Bai 2
#include <iostream>

using namespace std;

int gcd(int a, int b){
	if(b == 0) return a;
	return gcd(b,a%b);
}
int lcm(int a, int b){
	return a/gcd(a,b)*b;
}

int main(){
	freopen("tn.inp","r",stdin);
	freopen("tn.out","w",stdout);

	int n, bc = 1; cin >> n;
	int a[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n; i++) bc = lcm(bc, a[i]);

	cout << bc << endl;
	for(int i = 0; i < n; i++) cout << bc/a[i] << " ";
	cout << endl;

	return 0;
}
Leave a Comment