Cod sursa(job #243712)
| Utilizator | Data | 13 ianuarie 2009 21:34:04 | |
|---|---|---|---|
| Problema | Oz | Scor | 20 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.48 kb |
// oz.cpp : Defines the entry point for the console application.
//
#include <stdio.h>
int e[10004];
int main()
{
int a,b,c,i,j,m,n;
FILE *f1,*f2;
f1=fopen("oz.in","r");
f2=fopen("oz.out","w");
fscanf(f1,"%d %d",&n,&m);
for(i=1;i<=n;i++)
e[i]=1;
for(i=1;i<=m;i++)
{
fscanf(f1,"%d %d %d",&a,&b,&c);
if(e[a]%c!=0)
e[a]=e[a]*c;
if(e[b]%c!=0)
e[b]=e[b]*c;
}
for(i=1;i<=n;i++)
fprintf(f2,"%d ",e[i]);
fclose(f1);
fclose(f2);
return 0;
}
