Pagini recente » Cod sursa (job #782952) | Cod sursa (job #865617) | Cod sursa (job #2294170) | Cod sursa (job #1239805) | Cod sursa (job #1486247)
#include<fstream>
#include<queue>
#include<cstdlib>
#include<iostream>
using namespace std;
ifstream fin ("multiplu.in");
ofstream fout ("multiplu.out");
queue <int> q;
int A,AA,B,BB,M,aux;
int CMMDC,CMMMC;
int cmmdc(long long int A, long long int B)
{
int R;
while (B!=0)
{
R=A%B;
A=B;
B=R;
}
return A;
}
void Citire()
{
fin >> A >> B;
AA=A; BB=B;
CMMDC = cmmdc(A,B);
A=AA; B=BB;
CMMMC = (A*B)/CMMDC;
}
void Rezolva()
{
int x,y;
/// M = CMMMC
q.push(1);
while (!q.empty())
{
x = q.front();
q.pop();
y = x * 10;
if (y%CMMMC == 0)
{
fout << y << "\n";
exit(0);
}
else
{
q.push(y);
}
y++;
if (y%CMMMC == 0)
{
fout << y << "\n";
exit(0);
}
else
{
q.push(y);
}
}
}
int main ()
{
Citire();
Rezolva();
fin.close();
fout.close();
return 0;
}