Pagini recente » Cod sursa (job #2755540) | Cod sursa (job #2597049) | Cod sursa (job #277040) | Cod sursa (job #2004063) | Cod sursa (job #3140444)
#include<bits/stdc++.h>
#define mod 1000000007
#define inf 0x3f3f3f3f
#define bit(x,i)(((x)>>(i))&1)
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
ifstream fin("multiplu.in");
ofstream fout("multiplu.out");
typedef long long ll;
const long long int mare=1LL*1000000000000000000;
ll T,n,m,ok,i,j,t,a,b;
char s[4000005];
ll suma,maxx,ans,minn,poz,contor,f[2000005],tata[2000005],cifra[2000005];
queue<ll> q;
int main()
{
fin>>a>>b;
m=(a*b)/__gcd(a,b);
q.push(1);
tata[1]=-1;
cifra[1]=1;
f[1]=1;
cout<<m<<"\n";
while(!q.empty())
{
int x=q.front();
q.pop();
int c=(x*10)%m;
int d=(x*10+1)%m;
if(!f[c])
{
f[c]++;
q.push(c);
tata[c]=x;
cifra[c]=0;
if(c==0)
{
break;
}
}
if(!f[d])
{
f[d]++;
q.push(d);
tata[d]=x;
cifra[d]=1;
if(d==0)
{
break;
}
}
}
vector<int> ans;
poz=tata[0];
ans.push_back(cifra[0]);
while(poz != -1)
{
ans.push_back(cifra[poz]);
poz=tata[poz];
}
for(i=ans.size()-1;i>=0;i--)
{
fout<<ans[i];
}
return 0;
}