Pagini recente » Cod sursa (job #782405) | Borderou de evaluare (job #3133721) | Cod sursa (job #1067274) | Cod sursa (job #796423) | Cod sursa (job #3270850)
#include <bits/stdc++.h>
using namespace std;
int cmmdc(int a, int b){
while(b){
int r = a % b;
a = b;
b = r;
}
return a;
}
int main(){
ifstream fin("oz.in");
ofstream fout("oz.out");
int n, t, a[10010];
fin >> n >> t;
for(int i = 1; i <= n; i++){
a[i] = 1;
}
for(int p = 1; p <= t; p++){
int i, j, cmd;
fin >> i >> j >> cmd;
a[i] = a[i] * (cmd / cmmdc(a[i], cmd));
a[j] = a[j] * (cmd / cmmdc(a[j], cmd));
}
for(int i = 1; i <= n; i++){
fout << a[i] << " ";
}
}