Pagini recente » Cod sursa (job #393297) | Cod sursa (job #954235) | Cod sursa (job #49676) | Cod sursa (job #1643930) | Cod sursa (job #2254681)
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("multiplu.in");
ofstream fout ("multiplu.out");
const int N = 2000002;
int a, b, p[N], last[N];
void hatz (int x) {
if (x != 1)
hatz(p[x]);
fout << last[x];
}
int main()
{
fin >> a >> b;
int nr = a * b / __gcd(a, b);
for (int i = 0; i < nr; i++)
last[i] = -1;
queue <int>q;
q.push(1);
last[1] = 1;
while (!q.empty()) {
int x = q.front();
q.pop();
int y = x * 10 % nr;
if (last[y] == -1) {
last[y] = 0;
p[y] = x;
q.push(y);
}
y = (10 * x + 1) % nr;
if (last[y] == -1) {
last[y] = 1;
p[y] = x;
q.push(y);
}
}
hatz(0);
return 0;
}