Cod sursa(job #3242536)

Utilizator Andrei1209Andrei Mircea Andrei1209 Data 12 septembrie 2024 16:03:30
Problema Multiplu Scor 10
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.63 kb
#include <fstream>

using namespace std;
ifstream fin("multiplu.in");
ofstream fout("multiplu.out");
int cmmdc( int a, int b)
{
    int rest;
    while ( b != 0 )
    {
        rest  = a % b;
        a = b;
        b = rest;
    }
    return a;
}
bool bun( long long x )
{
    while ( x > 0 )
    {
        if (x % 10 > 1)
            return false;
        x = x / 10;
    }
    return true;
}
int main()
{

    int a, b;
    long long x, i;
    fin >> a >> b;
    x = a * b / cmmdc(a, b);
    i = x;
    while ( bun(i) == false )
    {
        i += x;
    }
    fout << i << '\n';

    return 0;
}