Cod sursa(job #2218995)

Utilizator ioana_99Ioana Marin ioana_99 Data 6 iulie 2018 18:07:50
Problema Multiplu Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.51 kb
#include <iostream>

using namespace std;
int a,b;

void numere(long long x,long long y,int c)
{
    //cout<<"x "<<x<<" y "<<y<<endl;
    if((x%a==0 && x%b==0)|| c==10)
       {
           cout<<x;
           return;
       }
       else if((y%a==0 && y%b==0) || c==3)
        {
            cout<<y;
            return;
        }
    else
    {
        c++;
        numere(x*10,y*10,c);
        numere(x*10+1,y*10+1,c);
    }
}

int main()
{
    cin>>a>>b;
     numere(1,1,0);
    return 0;
}