Pagini recente » Istoria paginii utilizator/adrriann | Cod sursa (job #1718487) | Cod sursa (job #2236769) | Cod sursa (job #141108) | Cod sursa (job #2018485)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("multiplu.in");
ofstream fout("multiplu.out");
int A,B,rest[2000002];
queue<int>q;
int Cmmmc(int x,int y)
{
int r,a,b;
a=x;b=y;
while(y!=0)
{
r=x%y;
x=y;
y=r;
}
return (1LL*a*b)/x;
}
int main()
{
long long aux,v;
fin>>A>>B;
A=Cmmmc(A,B);
q.push(1);
rest[1]=1;
while(!q.empty() && rest[0]==0)
{
aux=q.front();
q.pop();
aux*=10;
v=aux%A;
if(rest[v]==0)
{
rest[v]=aux;
q.push(aux);
}
aux++;
v=aux%A;
if(rest[v]==0)
{
rest[v]=aux;
q.push(aux);
}
}
fout<<rest[0]<<"\n";
return 0;
}