Cod sursa(job #3306053)

Utilizator petric_mariaPetric Maria petric_maria Data 7 august 2025 00:05:07
Problema Multiplu Scor 10
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.52 kb
#include <bits/stdc++.h>
using namespace std;
ifstream f("multiplu.in");
ofstream g("multiplu.out");

int a, b;
queue <int> q;

void solve () {
    bool ok = true;
    q.push (1);
    while (ok && !q.empty()) {
        int k = q.front();  q.pop();
        if (k % a == 0 && k % b == 0) {
            ok = false;
            g << k;
        }
        else {
            q.push (k * 10);
            q.push (k * 10 + 1);
        }
    }
}

int main()
{
    f >> a >> b;
    solve ();
    return 0;
}