Cod sursa(job #2269784)

Utilizator sandupetrascoPetrasco Sandu sandupetrasco Data 26 octombrie 2018 16:41:40
Problema Multiplu Scor 10
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.63 kb
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
    ifstream cin("multiplu.in");
    ofstream cout("multiplu.out");
    int n, m;
    
    cin >> n >> m;
    
    int nr = 15;
    ll checker = 0, rs = 1e18;
    int L = 1 << nr;
    
    for (int i = 1; i < L; i++){
        checker = 0;
        
        for (int j = nr - 1; j >= 0; j--){
            if (i & (1 << j)){
                checker = checker + pow(10, j);
            }
        }
        
        if (checker % n == 0 && checker % m == 0)
            rs = min(rs, checker);
    }
    
    cout << rs;
    
    return 0;
}