Pagini recente » Cod sursa (job #1256528) | Cod sursa (job #1962996) | Cod sursa (job #2894002) | Cod sursa (job #2944855) | Cod sursa (job #2524350)
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("multiplu.in");
ofstream out("multiplu.out");
const int dim = 2000005;
long long int a,b,q[dim],prod;
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%prod == 0)
{
return now;
} else q[++dr] = now;
now = x*10 + 1;
if (now%prod == 0)
{
return now;
} else q[++dr] = now;
}
return 0;
}
int main()
{
in >> a >> b;
prod = a*b;
out << BFS();
return 0;
}