Cod sursa(job #114937)
| Utilizator | Data | 16 decembrie 2007 09:40:23 | |
|---|---|---|---|
| Problema | Multiplu | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | preONI 2008, Runda 2, Clasa a 10-a | Marime | 0.47 kb |
#include <fstream.h>
long cmmmc(long a,long b)
{ long p,r;
p=a*b;
while (a%b!=0)
{ r=a%b;
a=b;
b=r;
}
return p/b;
}
int verif(long long x)
{ while (x>0)
{ if (((x%10)!=0)&&((x%10)!=1)) return 0;
x=x/10;
}
return 1;
}
int main()
{ long a,b,m;
long long x;
ifstream f("multiplu.in");
ofstream g("multiplu.out");
f>>a>>b;
m=cmmmc(a,b);
x=m;
while (verif(x)==0) x=x+m;
g<<x;
f.close();
g.close();
return 0;
}
