Pagini recente » Cod sursa (job #2599549) | Cod sursa (job #1548741) | Cod sursa (job #2246265) | Cod sursa (job #1854255) | Cod sursa (job #1301049)
#include <fstream>
#include <cstdio>
#define pmax 2000005
using namespace std;
ifstream f("multiplu.in");
ofstream g("multiplu.out");
int c[pmax];
int r[pmax];
int cnt[pmax];
int n,a,b,mod1,mod2,t;
int sol[100],nr,p,u;
int main()
{ int i,j;
f>>a>>b;
n=a*b;
p=1;u=1;
c[1]=1;
cnt[1]=1;
while (p<=u){
mod1=(c[p]*10)%n;
mod2=(c[p]*10+1)%n;
if (cnt[mod1]==0) {c[++u]=mod1;
cnt[mod1]=u;
r[u]=p*10;}
if (cnt[mod2]==0) {c[++u]=mod2;
cnt[mod2]=u;
r[u]=p*10+1;}
p++;
}
t=cnt[0];
while (t>=2)
{sol[++nr]=r[t]%10;
t=r[t]/10;
}
sol[++nr]=1;
for (i=nr;i>=1;i--) g<<sol[i];
return 0;
}