Cod sursa(job #263566)

Utilizator mottyMatei-Dan Epure motty Data 20 februarie 2009 16:29:42
Problema Multiplu Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.47 kb
#include<stdio.h>

int cm(long a,long b)
{
	if(a%b)
		return a;
	return cm(b,a%b);
}

char binn(long long s)
{
	while(s)
	{
		if(s%10>1)
			return 0;
		s/=10;
	}
	return 1;
}

long long bun(long x)
{
	long long ix=x,p=x;
	while(binn(ix)==0)
		ix+=p;
	return ix;
}

int main()
{
	freopen("multiplu.in","r",stdin);
	freopen("multiplu.out","w",stdout);
	long a,b,x;
	scanf("%ld%ld",&a,&b);
	x=a*b/cm(a,b);
	printf("%lld",bun(x));
	return 0;
}