Pagini recente » Cod sursa (job #250241) | Cod sursa (job #1652304) | Cod sursa (job #1956996) | Cod sursa (job #1180103) | Cod sursa (job #545116)
Cod sursa(job #545116)
# include <stdlib.h>
# include <cstdio>
using namespace std;
long long rez;
int a, b, ok, ok1, sol[20];
int back(int k)
{int i;
if (k == 16)
{
rez = 0; ok = 0;
for (i = 1; i <= 15; 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("%lld",rez);
ok1 = 1;
}
/*for (i = 1; i <= 15; 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;
}