Cod sursa(job #1367912)

Utilizator StarGold2Emanuel Nrx StarGold2 Data 2 martie 2015 11:26:36
Problema Multiplu Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.55 kb
#include<fstream>
using namespace std;
ifstream fin("multiplu.in");
ofstream fout("multiplu.out");
long long vf(long long x){
    while(x!=0){
        if(x%10>1){
            return 1;
        }
        x/=10;
    }
    return 0;
}
int M,a,b,r;
long long m; int x,y,i;
int main(){
    fin>>x>>y;
    a=x;
    b=y;
    r=0;
    while(b!=0){
        r=a%b;
        a=b;
        b=r;
    }
    M=(x*y)/a;
    for(i=2;;i++){
        m=M*i;
        if(vf(m)==0){
            fout<<m;
            return 0;
        }
    }
    return 0;
}