Cod sursa(job #1671326)

Utilizator RaduXD1Nicolae Radu RaduXD1 Data 1 aprilie 2016 16:17:58
Problema Oz Scor 75
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.72 kb
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>

using namespace std;
ifstream fin ("oz.in");
ofstream fout("oz.out");
unsigned long long v[10010],i,j,d,h,n,m,u[10010],ok;

int cmmdc(unsigned long long a, unsigned long long b)
{
    unsigned long long r;
    while(b>0)
    {
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}

int main()
{
    fin>>n>>m;
    for(i=1;i<=n;i++)
        v[i]=1;
    for(h=1;h<=m;h++)
    {
        fin>>i>>j>>d;
        v[i]*=d/cmmdc(v[i], d);
        v[j]*=d/cmmdc(v[j], d);
        u[i]=1;
        u[j]=1;
    }
    if(ok==0)
    for(i=1;i<=n;i++)
        fout<<v[i]<<" ";
    fin.close();
    fout.close();
    return 0;
}