Pagini recente » Cod sursa (job #514402) | Cod sursa (job #1431903) | Cod sursa (job #3182202) | Cod sursa (job #540305) | Cod sursa (job #1802696)
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
FILE *IN,*OUT;
int A,B,GDN,LCM,i;
bool found=false;
int gdn(int a,int b)
{
if(a%b==0)return b;
else return gdn(b,a%b);
}
bool Check(int a)
{
bool val=true;
while(a)
{
if(a%10>1){val=false;break;}
a/=10;
}
return val;
}
int main()
{
IN=fopen("multiplu.in","r");
OUT=fopen("multiplu.out","w");
fscanf(IN,"%d%d",&A,&B);
GDN=gdn(A,B);
LCM=A*B/GDN;
for(i=LCM;!found;i+=LCM)
{
found=Check(i);
if(found)break;
}
fprintf(OUT,"%d",i);
}