Pagini recente » Cod sursa (job #1852104) | Cod sursa (job #657200) | Cod sursa (job #2261397) | Cod sursa (job #131099) | Cod sursa (job #566284)
Cod sursa(job #566284)
#include <fstream>
using namespace std;
int gcd ( int a, int b ) {
int c;
while ( a ) {
c = b % a;
b = a;
a = c;
}
return b;
}
int lcm ( int a, int b ) {
int c = a * b;
c = c / gcd ( a, b );
return c;
}
bool only ( long long c ){
while ( c ) {
if ( c % 10 > 1 )
return false;
c /= 10;
}
return true;
}
int main () {
int a, b;
ifstream f ( "multiplu.in" );
f >> a >> b;
f.close();
int l = lcm ( a, b );
long long cl = l;
while ( ! only ( cl ) )
cl = cl + l;
ofstream g ( "multiplu.out" );
g << cl << endl;
g.close();
return 0;
}