Pagini recente » Cod sursa (job #2001767) | Cod sursa (job #1112868) | Cod sursa (job #3003340) | Cod sursa (job #1282779) | Cod sursa (job #391345)
Cod sursa(job #391345)
#include<fstream.h>
int cmmdc(unsigned long a,unsigned long b)
{
if(a<b) {a=a+b; b=a-b; a=a-b;}
int r=a%b;
while(r!=0)
{
a=b; b=r; r=a%b;
}
return b;
}
int main()
{
unsigned long a,b,cmmmc,ok=1,i=0,ok2,s;
ifstream fin("multiplu.in");
ofstream fout("multiplu.out");
fin>>a>>b;
cmmmc=a*b/cmmdc(a,b);
while(ok==1)
{
i++;
ok2=1;
s=cmmmc*i;
while(s!=0 && ok2==1)
{
int c=s%10;
s=s/10;
if(c>1) ok2=0;
}
if(ok2==1) ok=0;
}
fout<<i*cmmmc;
return 0;
}