Pagini recente » Cod sursa (job #645127) | Cod sursa (job #3146796) | Cod sursa (job #303813) | Cod sursa (job #2618227) | Cod sursa (job #3141604)
#include <bits/stdc++.h>
#define ll long long
#define ull unsinged ll
using namespace std;
ifstream fin("multiplu.in");
ofstream fout("multiplu.out");
int f[2000001];
int v[2000001];
int uc[2000001];
int cmmmc(int a, int b)
{
int gcd = __gcd(a, b);
return (a / gcd) * b;
}
void print(int ind)
{
if (ind == 1)
{
fout << 1;
return;
}
print(v[ind]);
fout << uc[ind];
}
int main()
{
int a, b;
fin >> a >> b;
int c = cmmmc(a, b);
queue<int> q;
q.push(1);
f[1] = 1;
while (!q.empty())
{
int top = q.front();
q.pop();
if (f[((top * 10) % c)] == 0)
{
q.push(((top * 10) % c));
f[(top * 10) % c] = 1;
v[(top * 10) % c] = top;
uc[(top * 10) % c] = 0;
}
if (f[((top * 10 + 1) % c)] == 0)
{
q.push((top * 10 + 1) % c);
f[(top * 10 + 1) % c] = 1;
v[(top * 10 + 1) % c] = top;
uc[(top * 10 + 1) % c] = 1;
}
}
print(0);
return 0;
}