Pagini recente » Cod sursa (job #1340561) | Cod sursa (job #3000006) | Cod sursa (job #30557) | Cod sursa (job #359318) | Cod sursa (job #1435935)
#include <fstream>
#include <vector>
#include <queue>
using namespace std;
ifstream fi("multiplu.in");
ofstream fo("multiplu.out");
queue <long long> q;
long long a,b,xa,xb, r[2000001];
int is01(long long x) {
while (x) {
if (x % 10 > 1) {
return 0;
}
x /= 10;
}
return 1;
}
int main() {
fi >> a >> b;
long long cmmmc = a*b;
q.push(1);
r[1] = 1;
long long rs;
while (1) {
long long aux = q.front();
q.pop();
if (!(aux % a) && !(aux % b)) {
fo << aux;
return 0;
}
if (!r[(aux * 10) % cmmmc]) {
r[(aux * 10) % cmmmc] = 1;
q.push(aux*10);
}
if (!r[(aux * 10 + 1) % cmmmc]) {
r[(aux * 10 + 1) % cmmmc] = 1;
q.push(aux*10 + 1);
}
}
return 0;
}