Cod sursa(job #275329)

Utilizator ooctavTuchila Octavian ooctav Data 10 martie 2009 13:18:43
Problema Multiplu Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.7 kb

#include <stdio.h>
int e[1000004];
int aux[10];
int a,b,cmm,a2;

void cmmmc()
{
	int a1=a,b1=b,r;
	while(b1)
	{
		r=a1%b1;
		a1=b1;
		b1=r;
	}
	cmm=a*b/a1;
}
void aflare()
{
	char b=0,i,t=0,cop=cmm;
	while(!b)
	{
		t=0;
		cop=cmm;
		b=1;
		for(i=1;cop || t;i++,t=t/10)
		{
			t=t+e[i]+cop%10;
			cop=cop/10;
			e[i]=t%10;
		}
		e[0]=i-1;
		for(i=1;i<=e[0];i++)
			if(e[i]!=0 && e[i]!=1)
			{
				b=0;
				break;
			}
	}
}

int main()
{
	int i,c;
	FILE *f1,*f2;
	f1=fopen("multiplu.in","r");
	f2=fopen("multiplu.out","w");
	fscanf(f1,"%d %d",&a,&b);
	cmmmc();
	aflare();
	for(i=1;i<=e[0];i++)
		fprintf(f2,"%d",e[i]);
	fclose(f1);
	fclose(f2);
	return 0;
}