Pagini recente » Cod sursa (job #1827601) | Cod sursa (job #2041001) | Cod sursa (job #1413962) | Cod sursa (job #389423) | Cod sursa (job #545120)
Cod sursa(job #545120)
# 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;
}
}
else
{
sol[k] = -1; if (ok1) return 0;
while (sol[k] < 1)
{
sol[k]++;
back(k+1);
}
}
}
int main()
{
freopen("multiplu.in","r",stdin);
freopen("multiplu.out","w",stdout);
scanf("%d%d",&a,&b);
back(1);
return 0;
}