Cod sursa(job #429493)

Utilizator Teodor94Teodor Plop Teodor94 Data 30 martie 2010 11:04:06
Problema Multiplu Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.51 kb
#include<cstdio>

int cmmdc(int a,int b)
{
	int r;
	while (b)
	{
		r=a%b;
		a=b;
		b=r;
	}
	return a;
}

bool verif(int x)
{
	while (x)
	{
		if (x%10!=0 && x%10!=1)
			return false;
		x/=10;
	}
	return true;
}

int main()
{
	freopen("multiplu.in","r",stdin);
	freopen("multiplu.out","w",stdout);
	int a,b;
	scanf("%d%d",&a,&b);
	int cmmmc=(a*b)/cmmdc(a,b);
	for (int i=1;i<=a*b;i++)
	{
		int x=cmmmc*i;
		if (verif(x))
		{
			printf("%d\n",x);
			return 0;
		}
	}
	return 0;
}