Pagini recente » Monitorul de evaluare | Cod sursa (job #2239969) | Cod sursa (job #1383940) | Colors | Cod sursa (job #473668)
Cod sursa(job #473668)
#include <fstream>
using namespace std;
long long a[10100];
int n,m;
int gcd(int x, int y) {
if (y == 0)
return x;
return gcd(y, x % y);
}
int main() {
ifstream fin("oz.in");
ofstream fout("oz.out");
fin >> n >> m;
for (int i = 1; i <= n; ++i)
a[i] = 1;
while (m--) {
int i,j,k;
fin >> i >> j >> k;
a[i] = a[i]*k / gcd(a[i], k);
a[j] = a[j]*k / gcd(a[j], k);
}
for (int i = 1; i < n; ++i)
fout << a[i] << " ";
fout << a[n] << "\n";
fout.close();
return 0;
}