Cod sursa(job #3376024)
| Utilizator | Data | 15 noiembrie 2026 14:01:45 | |
|---|---|---|---|
| Problema | Oz | Scor | 10 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.4 kb |
#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin("oz.in");
ofstream fout("oz.out");
long long n,q,i,j,d,v[100005]={1};
int main()
{
fin>>n>>q;
for(int i=1;i<=n;i++)v[i]=1;
while(q--){
fin>>i>>j>>d;
long long mlt=__gcd(v[i],v[j]);
d/=mlt;
v[i]*=d,v[j]*=d;
}
for(int i=1;i<=n;i++)fout<<v[i]<<" ";
return 0;
}
