Pagini recente » Cod sursa (job #2867779) | Cod sursa (job #1767169) | Cod sursa (job #36143) | Cod sursa (job #2171861) | Cod sursa (job #2524347)
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("multiplu.in");
ofstream out("multiplu.out");
const int dim = 1000005;
long long int a,b,q[dim];
int st = 0;
int dr = -1;
long long int BFS()
{
q[++dr] = 1;
while (1)
{
long long int x = q[st++];
long long int now = x*10;
if (now%a == 0 && now%b == 0)
{
return now;
} else q[++dr] = now;
now = x*10 + 1;
if (now%a == 0 && now%b == 0)
{
return now;
} else q[++dr] = now;
}
return 0;
}
int main()
{
in >> a >> b;
out << BFS();
return 0;
}