Pagini recente » Cod sursa (job #2165906) | Cod sursa (job #2592594) | Cod sursa (job #754824) | Cod sursa (job #2657821) | Cod sursa (job #2656608)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("oz.in");
ofstream fout("oz.out");
long long n,m,d,a,b,ok,q,i;
long long v[10005];
int main()
{fin>>n>>m;
for(i=1;i<=m;i++)
{
fin>>a>>b>>d;
if(v[a]==0)
{
v[a]=1;
ok++;
}
if(v[b]==0)
{
v[b]=1;
ok++;
}
q=__gcd(d,v[a]);
v[a]=1LL*(d*v[a])/q;
q=__gcd(d,v[b]);
v[b]=1LL*(v[b]*d)/q;
}
for(i=1;i<=n;i++)fout<<v[i]<<" ";
return 0;
}