Pagini recente » Cod sursa (job #1882452) | Cod sursa (job #1805064) | Cod sursa (job #2779751) | Cod sursa (job #1937080) | Cod sursa (job #2313215)
#include <bits/stdc++.h>
using namespace std;
ifstream in ("multiplu.in");
ofstream out("multiplu.out");
queue <int> q;
int A,B,C,pred[5000005],fin[5000005],v[2000005],loc;
int get_C()
{
int a=A,b=B,c;
while (b)
{
c=a%b;
a=b;
b=c;
}
return a;
}
stack <int>st;
void output()
{
while (loc)
{
st.push(loc%2);
loc/=2;
}
while (!st.empty()){out<<st.top();st.pop();}
out<<"\n";
out.close();
in.close();
}
int main()
{int x;
in>>A>>B;
C=(A*B)/get_C();
q.push(1);
while (!q.empty())
{
loc++;
x=q.front();
q.pop();
if (x==0)
{
output();
return 0;
}
q.push(1LL*x*10%C);
q.push((1LL*x*10+1)%C);
}
return 0;
}