Pagini recente » Cod sursa (job #2884939) | Cod sursa (job #664118) | Cod sursa (job #3247036) | Cod sursa (job #2340476) | Cod sursa (job #2271213)
#include <bits/stdc++.h>
#define ios ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define enter cout << '\n'
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <pii > vii;
typedef vector <ll> vl;
typedef vector <pll > vll;
typedef queue <int> qi;
typedef queue <pii > qii;
typedef queue <ll> ql;
typedef queue <pll > qll;
const int INF = 1000000000;
const int MOD = 104659;
const int EPSILON = 0.0000000001;
const int NMAX = 1e5 + 5;
const int ABMAX = 2e6 + 5;
ifstream fin("multiplu.in");
ofstream fout("multiplu.out");
int a, b, m, l = 0, r = 1;
int up[ABMAX], cif[ABMAX], q[ABMAX];
bool vis[ABMAX];
int gcd(int x, int y)
{
if (y == 0) return x;
return gcd(y, x % y);
}
void write(int i)
{
if (up[i] == 0)
{
fout << cif[i];
return;
}
write(up[i]);
fout << cif[i];
}
int main()
{
fin >> a >> b;
m = (a * b) / gcd(a, b);
vis[1] = true;
q[1] = 1;
cif[1] = 1;
while (!vis[0])
{
++l;
if (!vis[(q[l] * 10) % m])
{
vis[(q[l] * 10) % m] = true;
q[++r] = (q[l] * 10) % m;
up[r] = l;
cif[r] = 0;
}
if (q[0]) break;
if (!vis[(q[l] * 10 + 1) % m])
{
vis[(q[l] * 10 + 1) % m] = true;
q[++r] = (q[l] * 10 + 1) % m;
up[r] = l;
cif[r] = 1;
}
}
write(r);
return 0;
}