Pagini recente » Rating ivan marian liviu (marian77) | Cod sursa (job #1297070) | Cod sursa (job #2869079) | Cod sursa (job #1665964) | Cod sursa (job #2269614)
#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");
ql q;
int a, b, m;
bool vis[ABMAX];
int gcd(int x, int y)
{
if (y == 0) return x;
return gcd(y, x % y);
}
int main()
{
fin >> a >> b;
m = (a * b) / gcd(a, b);
q.push(1);
vis[1] = true;
while (q.front() % m != 0)
{
if (!vis[(q.front() * 10) % m])
{
vis[(q.front() * 10) % m] = true;
q.push(q.front() * 10LL);
}
if (!vis[(q.front() * 10 + 1) % m])
{
vis[(q.front() * 10 + 1) % m] = true;
q.push(q.front() * 10LL + 1);
}
q.pop();
}
fout << q.front();
return 0;
}