Cod sursa(job #545107)

Utilizator idomiralinIdomir Alin idomiralin Data 2 martie 2011 18:31:23
Problema Multiplu Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.18 kb
# include <stdlib.h>
# include <cstdio>

using namespace std;

int ct, a, b, rez, ok, ok1, sol[10000]; 
int back(int k)
{int i;
     if (k == 11)
     {
           
           rez = 0; ok = 0;
           for (i = 1; i <= 10; i++)
           if (sol[i]) 
           {
                       rez = rez * 10 + sol[i];
                       ok = 1;
                       }
           else 
           if (ok)
           {
                  rez = rez * 10;
                  } 
           if (rez % a == 0 && rez % b == 0 && rez != 0) 
           {
                   printf("%d",rez);
                   ok1 = 1;
                   }
           
           /*for (i = 1; i <= 4; i++)
           printf("%d",sol[i]);
           if (i = 4) printf("\n");*/
           }
     else
     {
         sol[k] = -1;
         while (sol[k] < 1)
         {
                if (ok1) return 0;
                sol[k]++;
                back(k+1);
                }
         }
         
}
               
int main()
{int i, j;
    freopen("multiplu.in","r",stdin);
    freopen("multiplu.out","w",stdout);
    
    scanf("%d%d",&a,&b);
    
    back(1);
    
return 0;
}