Pagini recente » Cod sursa (job #1374918) | Cod sursa (job #388253) | Cod sursa (job #1359140) | Cod sursa (job #950295) | Cod sursa (job #2979265)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("multiplu.in");
ofstream fout("multiplu.out");
long long a, b, m, x;
queue<long long> q;
int main() {
fin >> a >> b;
m = a * b;
long long rest = a % b;
while(rest) {
a = b;
b = rest;
rest = a % b;
}
m /= b;
q.push(1);
if(1 % m == 0) {
fout << 1;
return 0;
}
while(!q.empty()) {
x = q.front();
if((x * 10) % m == 0) {
fout << x * 10;
return 0;
}
q.push(x * 10);
if((x * 10 + 1) % m == 0) {
fout << x * 10 + 1;
return 0;
}
q.push(x * 10 + 1);
q.pop();
}
return 0;
}