Pagini recente » Cod sursa (job #2802816) | Cod sursa (job #1308421) | Cod sursa (job #203680) | Cod sursa (job #376207) | Cod sursa (job #2979253)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("multiplu.in");
ofstream fout("multiplu.out");
int a, b, m, x;
queue<int> q;
bitset<100002> fr;
static inline long long cmmdc(long long a, long long b) {
long long rest = a % b;
while(rest) {
a = b;
b = rest;
rest = a % b;
}
return b;
}
int main() {
fin >> a >> b;
m = a * b / cmmdc(a, b);
q.push(1);
fr[1] = 1;
while(q.front() % m != 0) {
x = q.front();
if(x % m == 0) break;
if(!fr[x * 10]) q.push(x * 10);
if(!fr[x * 10 + 1]) q.push(x * 10 + 1);
q.pop();
}
fout << q.front();
return 0;
}