Mai intai trebuie sa te autentifici.

Cod sursa(job #1486250)

Utilizator justsomedudePalade Thomas-Emanuel justsomedude Data 14 septembrie 2015 14:20:22
Problema Multiplu Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.13 kb
#include<fstream>
#include<queue>
#include<cstdlib>
#include<iostream>
using namespace std;

ifstream fin ("multiplu.in");
ofstream fout ("multiplu.out");

queue <unsigned long long int> q;
unsigned long long int A,AA,B,BB,M,aux;
unsigned long long int CMMDC,CMMMC;

int cmmdc(unsigned long long int A,unsigned long long int B)
{
   unsigned long long int R;
   while (B!=0)
  {
    R=A%B;
    A=B;
    B=R;
  }
  return A;
}

void Citire()
{
  fin >> A >> B;
  AA=A; BB=B;
  CMMDC = cmmdc(A,B);
  A=AA; B=BB;
  CMMMC = (A*B)/CMMDC;
}


void Rezolva()
{
  unsigned long long int x,y;
  /// M = CMMMC
  q.push(1);

  while (!q.empty())
  {
      x = q.front();
      q.pop();
      y = x * 10;


      if (y%CMMMC == 0)
      {
          fout << y << "\n";
          exit(0);
      }

      else
      {
          q.push(y);
      }

      y++;

      if (y%CMMMC == 0)
      {
          fout << y << "\n";
          exit(0);
      }

      else
      {
          q.push(y);
      }
  }
}


int main ()
{
  Citire();
  Rezolva();
  fin.close();
  fout.close();
  return 0;
}