Cod sursa(job #2551846)
Utilizator | Cismaru Theodor-Alexe Theo20067 | Data | 20 februarie 2020 11:43:29 |
---|---|---|---|
Problema | Multiplu | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.91 kb |
#include <fstream>
using namespace std;
ifstream fin ("multiplu.in");
ofstream fout("multiplu.out");
int a,b,x,y,r,m,p,u,k,ok,crt,C[2000010],U[2000010],V[2000010],t[2000010];
void T(int u)
{
if(u!=0)
{
T(t[u]);
fout<<U[u];
}
}
int main ()
{
fin>>a>>b;
x=a;
y=b;
while(y!=0)
{
r=x%y;
x=y;
y=r;
}
m=a/x*b;
C[1]=1;
p=1;
u=1;
V[1]=1;
U[1]=1;
while(p<=u&&ok==0)
{
for(k=0;k<=1;k++)
{
crt=(C[p]*10+k)%m;
if(V[crt]==0)
{
u++;
C[u]=crt;
V[crt]=1;
U[u]=k;
t[u]=p;
if(crt==0)
{
ok=1;
break;
}
}
}
p++;
}
T(u);
return 0;
}