Pagini recente » Cod sursa (job #2912470) | Cod sursa (job #1936776) | Cod sursa (job #3209486) | Cod sursa (job #2572656) | Cod sursa (job #392170)
Cod sursa(job #392170)
#include<cstdio>
using namespace std;
#include<queue>
int a,b,c;
int cmmdc()
{
int r;
while (!b)
{
r=a%b;
a=b;
b=r;
}
return a;
}
queue<int>q;
void bf()
{
q.push(1);
int x,y;
while (true)
{
x=q.front();
q.pop();
y=x*10%c;
++b;
if (!y)
return;
q.push(y);
y=(x*10+1)%c;
++b;
if (!y)
return;
q.push(y);
}
}
void afis(int b)
{
if (!b)
return;
if (b&1)
{
afis(b>>1);
printf("0");
}
else
{
afis((b-1)>>1);
printf("1");
}
}
int main()
{
freopen("multiplu.in","r",stdin);
freopen("multiplu.out","w",stdout);
scanf("%d%d",&a,&b);
int p=a*b;
c=p/cmmdc();
bf();
printf("1");
afis(b);
return 0;
}