Cod sursa(job #123082)

Utilizator RobytzzaIonescu Robert Marius Robytzza Data 14 ianuarie 2008 16:57:42
Problema Multiplu Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.7 kb
#include <fstream.h>
#include <math.h>
ifstream fin("multiplu.in");
ofstream fout("multiplu.out");

int a,b,m;
long x;

void citire()
{
   fin>>a>>b;
   fin.close();
}

void cmd()
{
   int aa=a,bb=b;
   while (bb)
   {
     int r=aa%bb;
     aa=bb;
     bb=r;
   }
   m=a*b/aa;
}

void formare()
{
x=1;
   while (1)
   {
    if (x%m==0)
	return ;
    int nr=0;
    long aux=x;
    while (aux%10)
    {
       nr++;
       aux/=10;
    }
    if (x%10==0)
       x++;
    else
    {
      (x/=(pow(10,nr)));
      x++;
      x*=(pow(10,nr));
    }
   }
}

int main()
{
   citire();
   cmd();
   formare();
   fout<<x<<"\n";
   fout.close();
   return 0;
}