Cod sursa(job #2330415)

Utilizator theo2003Theodor Negrescu theo2003 Data 28 ianuarie 2019 12:40:36
Problema Multiplu Scor 10
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.73 kb
#include <fstream>
#include <sstream>
using namespace std;
ifstream in("multiplu.in");
ofstream out("multiplu.out");
int cmmdc(int a, int b){
    while((a!=0)&&(b!=0)){
        if(a>b){
            a%=b;
        }else{
            b%=a;
        }
    }
    return (a==0) ? b : a;
}
int main(){
    int a, b;
    in>>a>>b;
    stringstream ss;
    int cmmmc = a*b/cmmdc(a, b);
    //out<<cmmdc(a, b)<<' ';
    string out_;
    for(long long int x = cmmmc;true;x+=cmmmc){
        ss = stringstream();
        ss<<x;
        ss>>out_;
        for(char c : out_){
            if(c > '1'){
                goto no;
            }
        }
        out<<x;
        return 0;
        no:continue;
    }
    return 0;
}