167 条题解
-
-1张嘉盛 LV 4 @ 2017-05-15 13:00:20
马志马志是傻逼
-
-12017-05-14 22:15:46@
C++手打高精度的,啥也不说了,朕给你们跪下了
-
-12017-05-07 22:20:28@
直接gcd
#include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <iomanip> #include <cstdlib> using namespace std; int n,m; int gcd(int a,int b) { return b==0?a:gcd(b,a%b); } int main() { cin>>n>>m; int x=gcd(n,m); cout<<n*m/x; return 0; }
-
-12017-03-10 23:57:22@
Java大法好
```Java
import java.math.BigInteger;
import java.util.Scanner;public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String a = in.next();
String b = in.next();
BigInteger s1 = new BigInteger(a);
BigInteger s2 = new BigInteger(b);
System.out.println(s1.multiply(s2).divide(s1.gcd(s2)));}
} -
-12016-11-04 20:38:35@
#include <iostream>
using namespace std;
int MinY(int a,int b)
{
int min, max;
int r;
max=a>b?a:b;
min=a<b?a:b;
if(max%min==0)
return max;
while(max%min!=0)
{
r=max%min;
max=min;
min=r;
}
return a*b/min;
}
int main()
{
int a,b;
cin>>a>>b;
cout<<MinY(a,b)<<endl;
return 0;
} -
-12016-11-01 17:57:17@
----------python大法好!----------
f=[];
for x in raw_input().split(' '):
f.append(int(x))
a=f[0];b=f[1];s=a;bs=b;c=0;
while(b!=0):
c=a%b;a=b;b=c;
s=(s*bs)/a;
print s -
-12016-10-23 16:14:10@
手打高精打到残
c++
#include<iostream>
#include<string>
#define BASE 10
using namespace std;
string sAtimesB(string sA, string sB);
string sDiv(string sA, string sB);
string sSub(string sA, string sB);
string sBase = "0123456789ABCDEFG";
bool bBig(string sA, string sB);
int main()
{
string sA, sB, sT, sTA, sTB;
while (cin >> sA >> sB)
{
sTA = sA;
sTB = sB;
if (!bBig(sA, sB))
{
sT = sA;
sA = sB;
sB = sT;
}
while (sA != sAtimesB(sDiv(sA, sB), sB))
{
sT = sA;
sA = sB;
sB = sSub(sT, sAtimesB(sDiv(sT, sB), sB));
}
cout << sDiv(sAtimesB(sTA, sTB), sB) << endl;
}
return 0;
}
string sAtimesB(string sA, string sB)
{
string sRet;
int i, j, nLen1, nLen2;
int nA, nB, nC, nCa, nTA, nTB, nT1, nT2, nT3, nT4;
if ((sA == "0") || (sB == "0"))
{
return "0";
}
nLen1 = sA.size();
nLen2 = sB.size();
sRet.resize(nLen1 + nLen2, '0');
for (i = 0; i < nLen1; i++)
{
nA = nLen1 - 1 - i;
nCa = 0;
for (j = 0; j < nLen2; j++)
{
nB = nLen2 - 1 - j;
nT1 = sA[nA] - '0';
nT2 = sB[nB] - '0';
nC = nLen1 + nLen2 - 1 - (i + j);
nTA = sRet[nC] - '0';
nT3 = nT1*nT2 + nTA + nCa;
nT4 = nT3%BASE;
sRet[nC] = sBase[nT4];
nCa = nT3 / BASE;
}
nC--;
nTB = sRet[nC] - '0';
sRet[nC] = (char)(nTB + nCa + '0');
}
nT4 = (int)(sRet[0] - '0') % BASE;
nT3 = (int)(sRet[0] - '0') / BASE;
if (nT3>0)
{
sRet[0] = nT4;
sRet = (char)(nT3 + '0') + sRet;
}
while (sRet[0] == '0')
{
sRet = sRet.substr(1, nLen1 + nLen2 - 1);
}
return sRet;
}
string sDiv(string sA, string sB)
{
string sT, sTarget = "", sRet = "", sTmp, sT1;
int nAi = 0, i;
if (!bBig(sA, sB) || sA == "0")
return "0";
while (bBig(sB, sTarget))
{
sTarget = sTarget + sA[nAi];
nAi++;
}
while (nAi <= sA.size())
{
for (i = 0; i < 10; i++)
{
sTmp = "";
sTmp = (char)(i + '0') + sTmp;
sT = sAtimesB(sTmp, sB);
sT1 = sSub(sTarget, sT);
if (bBig(sB, sT1))
{
sRet = sRet + (char)(i + '0');
if (nAi != sA.size())
sTarget = sT1 + sA[nAi];
break;
}
}
nAi++;
}
return sRet;
}
bool bBig(string sA, string sB)
{
int nLenA = sA.size(), nLenB = sB.size();
if (nLenA < nLenB)
return false;
if (nLenA > nLenB)
return true;
if (sA > sB)
return true;
return false;
}
string sSub(string sA, string sB)
{
string sT, sRet = "";
int nLenA, nLenB, i, j, nSub = 0, nA, nB;
bool bZero = false;
if (sA == sB)
return "0";
if (sA.size() < sB.size())
{
bZero = true;
sT = sA;
sA = sB;
sB = sT;
}
else
{
if (sA.size() == sB.size())
{
if (sA < sB)
{
bZero = true;
sT = sA;
sA = sB;
sB = sT;
}
}
}
nLenA = sA.size();
nLenB = sB.size();
for (i = 0; i < (nLenA - nLenB); i++)
sB = "0" + sB;
for (i = nLenA - 1; i >= 0; i--)
{
nA = (int)(sA[i] - '0');
nB = (int)(sB[i] - '0');
nA -= nSub;
if (nA < nB)
{
nA += 10;
nSub = 1;
}
else
nSub = 0;
sRet = char((nA - nB) + '0') + sRet;
}
while (sRet[0] == '0')
sRet = sRet.substr(1, sRet.size() - 1);
if (bZero)
sRet = '-' + sRet;
return sRet;
}
-
-12016-09-03 17:52:48@
import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String args[]){ Scanner cin = new Scanner(System.in); String s1 = cin.next(), s2 = cin.next(); BigInteger a = new BigInteger(s1), b = new BigInteger(s2); System.out.println(a.multiply(b).divide(a.gcd(b)).toString()); cin.close(); } }
-
-12016-08-31 16:06:11@
PASCAL 50分
var
m,n,a,b,r:int64;
begin
readln(a,b);
m:=a;
n:=b;
r:=m mod n;
while r<>0 do
begin
m:=n;
n:=r;
r:=m mod n;
end;
writeln(a * b div n);
end. -
-12016-07-30 11:06:55@
人生苦短啊
```
a, b = map(lambda x : int(x), str.split(raw_input()))
def gcd(a, b):
if b == 0:
return a
else:
return gcd(b, a%b)print gcd(a, b)
``` -
-12016-07-26 17:46:05@
评测状态 Accepted
题目 P1047 最小公倍数
递交时间 2016-07-26 17:45:20
代码语言 C++
评测机 ShadowShore
消耗时间 15 ms
消耗内存 560 KiB
评测时间 2016-07-26 17:45:21评测结果
编译成功
测试数据 #0: Accepted, time = 0 ms, mem = 556 KiB, score = 10
测试数据 #1: Accepted, time = 0 ms, mem = 556 KiB, score = 10
测试数据 #2: Accepted, time = 0 ms, mem = 556 KiB, score = 10
测试数据 #3: Accepted, time = 0 ms, mem = 556 KiB, score = 10
测试数据 #4: Accepted, time = 0 ms, mem = 552 KiB, score = 10
测试数据 #5: Accepted, time = 0 ms, mem = 556 KiB, score = 10
测试数据 #6: Accepted, time = 15 ms, mem = 556 KiB, score = 10
测试数据 #7: Accepted, time = 0 ms, mem = 556 KiB, score = 10
测试数据 #8: Accepted, time = 0 ms, mem = 552 KiB, score = 10
测试数据 #9: Accepted, time = 0 ms, mem = 560 KiB, score = 10
Accepted, time = 15 ms, mem = 560 KiB, score = 100
代码
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
char s1[110],s2[110];
int num1[210],num2[210],num3[210],num4[210];
int len1,len2,len3,len4;
int ans[210];
int ansmax;
bool cmp()
{
if(len1>len2)return false;
if(len1<len2)return true;
for(int i=len1+1;i>=1;i--)
{
if(num1[i]<num2[i]) return true;
if(num1[i]>num2[i]) return false;
}
return false;
}
int main()
{
scanf("%s %s",s1,s2);
len1=strlen(s1)-1;
len2=strlen(s2)-1;for(int i=len1;i>=0;i--)num1[len1-i+1]=s1[i]-'0';
for(int i=len2;i>=0;i--)num2[len2-i+1]=s2[i]-'0';len1++;
len2++;
for(;;)
{
if(cmp())
{
int temp=len1;
len1=len2;
len2=temp;
memset(num3,0,sizeof(num3));
memcpy(num3,num2,sizeof(num2));
memcpy(num2,num1,sizeof(num1));
memcpy(num1,num3,sizeof(num3));
}
if(len2==0&&num2[1]==0)break;
int own=0;
int pos=len1-len2;
for(int i=len1,j=len2;j>0;j--,i--)
{
if(num1[i]>num2[j])break;if(num1[i]<num2[j]){
pos--;
break;
}
}
own=0;
for(int i=1;i<=len2||own;i++)
{
num1[i+pos]-=num2[i]+own;
own=0;
if(num1[i+pos]<0)
{
num1[i+pos]+=10;
own=1;
}
}
for(;!num1[len1]&&len1>0;len1--);
for(;!num2[len2]&&len2>0;len2--);
}len3=len1;
memset(num3,0,sizeof(num3));
memcpy(num3,num1,sizeof(num1));len1=strlen(s1)-1;
len2=strlen(s2)-1;for(int i=len1;i>=0;i--)num1[len1-i+1]=s1[i]-'0';
for(int i=len2;i>=0;i--)num2[len2-i+1]=s2[i]-'0';len1++;
len2++;int in=0;
for(int i=1;i<=len1;i++)
for(int j=1;j<=len2||in;j++)
{
num4[i+j-1]+=num1[i]*num2[j]+in;
in=num4[i+j-1]/10;
num4[i+j-1]%=10;
len4=max(len4,i+j-1);
}memcpy(num1,num4,sizeof(num4));
memcpy(num2,num3,sizeof(num3));for(;;)
{if(len4==0&&num1[1]==0)break;
int own=0;
int pos=len4-len3;
for(int i=len4,j=len3;i>0;j--,i--)
{
if(num1[i]>num2[j])break;if(num1[i]<num2[j]){
pos--;
break;
}
}
own=0;
for(int i=1;i<=len3||own;i++)
{
num1[i+pos]-=num2[i]+own;
own=0;
if(num1[i+pos]<0)
{
num1[i+pos]+=10;
own=1;
}}
ans[pos+1]++;
ansmax=max(pos+1,ansmax);
for(;!num1[len4]&&len4>0;len4--);
for(;!num2[len3]&&len3>0;len3--);
}
for(int i=ansmax;i>=1;i--) printf("%d",ans[i]);
} -
-12016-05-10 21:54:27@
python大法好
-
-12016-05-01 20:47:11@
Python大法好
天灭Pascaldef gcd(a, b): while b != 0: a, b = b, a % b return a a, b=[int(x) for x in raw_input().split(" ")] print(a * b / gcd(a, b))
-
-12016-04-25 21:16:49@
100(pascal)^-^zhichiyixia
-
-12016-04-25 21:16:00@
const
maxlen=500; type
hp=record len:integer; s:array[0..maxlen] of integer end; var
x:array[1..2] of hp; g,ans,mul:hp; i:longint; procedure init;
var st:string; s:array[1..2]of string; i,j:integer; begin readln(st); s[1]:=copy(st,1,pos(' ',st)-1); delete(st,1,pos(' ',st)); s[2]:=st; for j:=1 to 2 do begin x[j].len:=length(s[j]); for i:=1 to x[j].len do x[j].s[i]:=ord(s[j][x[j].len-i+1])-48 end end; procedure subtract(a,b:hp;var c:hp);
var i,len:integer; begin fillchar(c,sizeof(c),0); if a.len>b.len then len:=a.len else len:=b.len; for i:=1 to len do begin inc(c.s[i],a.s[i]-b.s[i]); if c.s[i]<0 then begin inc(c.s[i],10); dec(c.s[i+1]) end end; while(len>1) and (c.s[len]=0) do dec(len); c.len:=len end; function compare(const a,b:hp):integer;
var len:integer; begin if a.len>b.len then len:=a.len else len:=b.len; while (len>0)and(a.s[len]=b.s[len]) do dec(len); if len=0 then compare:=0 else compare:=a.s[len]-b.s[len] end; procedure multiply10(var a:hp);
var i:integer; begin for i:=a.len downto 1 do a.s[i+1]:=a.s[i]; a.s[1]:=0; inc(a.len); while (a.len>1)and(a.s[a.len]=0) do dec(a.len); end; procedure multiply(a,b:hp; var c:hp);
var i,j,x:longint; begin fillchar(c,sizeof(c),0); for i:=1 to a.len do begin x:=0; for j:=1 to b.len do begin x:=x+a.s[i]*b.s[j]+c.s[i+j-1]; c.s[i+j-1]:=x mod 10; x:=x div 10; end; c.s[i+j]:=x end; c.len:=a.len+b.len+1; while (c.s[c.len]=0)and(c.len>1) do dec(c.len) end; procedure divide(a,b:hp; var c,d:hp);
var i,j,len:integer; begin fillchar(c,sizeof(c),0); len:=a.len; fillchar(d,sizeof(d),0); d.len:=1; for i:=len downto 1 do begin multiply10(d); d.s[1]:=a.s[i]; while(compare(d,b)>=0) do begin subtract(d,b,d); inc(c.s[i]) end end; while(len>1)and(c.s[len]=0) do dec(len); c.len:=len end; function gcd(m,n:hp):hp;
var q,r:hp; begin if n.s[n.len]=0 then exit(m); divide(m,n,q,r); exit(gcd(n,r)) end; begin
init; g:=gcd(x[1],x[2]); multiply(x[1],x[2],mul); divide(mul,g,x[1],x[2]); for i:=x[1].len downto 1 do write(x[1].s[i]); writeln end. -
-12016-03-14 07:49:07@
评测结果
编译成功测试数据 #0: Accepted, time = 0 ms, mem = 556 KiB, score = 10
测试数据 #1: Accepted, time = 15 ms, mem = 556 KiB, score = 10
测试数据 #2: Accepted, time = 0 ms, mem = 556 KiB, score = 10
测试数据 #3: Accepted, time = 0 ms, mem = 552 KiB, score = 10
测试数据 #4: Accepted, time = 0 ms, mem = 556 KiB, score = 10
测试数据 #5: Accepted, time = 0 ms, mem = 556 KiB, score = 10
测试数据 #6: Accepted, time = 0 ms, mem = 556 KiB, score = 10
测试数据 #7: Accepted, time = 0 ms, mem = 552 KiB, score = 10
测试数据 #8: Accepted, time = 0 ms, mem = 552 KiB, score = 10
测试数据 #9: Accepted, time = 0 ms, mem = 556 KiB, score = 10
Accepted, time = 15 ms, mem = 556 KiB, score = 100
代码
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
char s1[110],s2[110];
int num1[210],num2[210],num3[210],num4[210];
int len1,len2,len3,len4;
int ans[210];
int ansmax;
bool cmp()
{
if(len1>len2)return false;
if(len1<len2)return true;
for(int i=len1+1;i>=1;i--)
{
if(num1[i]<num2[i]) return true;
if(num1[i]>num2[i]) return false;
}
return false;
}
int main()
{
scanf("%s %s",s1,s2);
len1=strlen(s1)-1;
len2=strlen(s2)-1;for(int i=len1;i>=0;i--)num1[len1-i+1]=s1[i]-'0';
for(int i=len2;i>=0;i--)num2[len2-i+1]=s2[i]-'0';len1++;
len2++;
for(;;)
{
if(cmp())
{
int temp=len1;
len1=len2;
len2=temp;
memset(num3,0,sizeof(num3));
memcpy(num3,num2,sizeof(num2));
memcpy(num2,num1,sizeof(num1));
memcpy(num1,num3,sizeof(num3));
}
if(len2==0&&num2[1]==0)break;
int own=0;
int pos=len1-len2;
for(int i=len1,j=len2;j>0;j--,i--)
{
if(num1[i]>num2[j])break;if(num1[i]<num2[j]){
pos--;
break;
}
}
own=0;
for(int i=1;i<=len2||own;i++)
{
num1[i+pos]-=num2[i]+own;
own=0;
if(num1[i+pos]<0)
{
num1[i+pos]+=10;
own=1;
}
}
for(;!num1[len1]&&len1>0;len1--);
for(;!num2[len2]&&len2>0;len2--);
}len3=len1;
memset(num3,0,sizeof(num3));
memcpy(num3,num1,sizeof(num1));len1=strlen(s1)-1;
len2=strlen(s2)-1;for(int i=len1;i>=0;i--)num1[len1-i+1]=s1[i]-'0';
for(int i=len2;i>=0;i--)num2[len2-i+1]=s2[i]-'0';len1++;
len2++;int in=0;
for(int i=1;i<=len1;i++)
for(int j=1;j<=len2||in;j++)
{
num4[i+j-1]+=num1[i]*num2[j]+in;
in=num4[i+j-1]/10;
num4[i+j-1]%=10;
len4=max(len4,i+j-1);
}memcpy(num1,num4,sizeof(num4));
memcpy(num2,num3,sizeof(num3));for(;;)
{if(len4==0&&num1[1]==0)break;
int own=0;
int pos=len4-len3;
for(int i=len4,j=len3;i>0;j--,i--)
{
if(num1[i]>num2[j])break;if(num1[i]<num2[j]){
pos--;
break;
}
}
own=0;
for(int i=1;i<=len3||own;i++)
{
num1[i+pos]-=num2[i]+own;
own=0;
if(num1[i+pos]<0)
{
num1[i+pos]+=10;
own=1;
}}
ans[pos+1]++;
ansmax=max(pos+1,ansmax);
for(;!num1[len4]&&len4>0;len4--);
for(;!num2[len3]&&len3>0;len3--);
}
for(int i=ansmax;i>=1;i--) printf("%d",ans[i]);
} -
-12016-02-21 11:10:30@
import java.io.*; import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in))); BigInteger a=sc.nextBigInteger(); BigInteger b=sc.nextBigInteger(); System.out.println(a.multiply(b).divide(a.gcd(b))); } }
-
-12015-12-12 16:38:19@
用qword可以拿5个点
-
-12015-11-24 12:08:20@
const
maxlen=500; type
hp=record len:integer; s:array[0..maxlen] of integer end; var
x:array[1..2] of hp; g,ans,mul:hp; i:longint; procedure init;
var st:string; s:array[1..2]of string; i,j:integer; begin readln(st); s[1]:=copy(st,1,pos(' ',st)-1); delete(st,1,pos(' ',st)); s[2]:=st; for j:=1 to 2 do begin x[j].len:=length(s[j]); for i:=1 to x[j].len do x[j].s[i]:=ord(s[j][x[j].len-i+1])-48 end end; procedure subtract(a,b:hp;var c:hp);
var i,len:integer; begin fillchar(c,sizeof(c),0); if a.len>b.len then len:=a.len else len:=b.len; for i:=1 to len do begin inc(c.s[i],a.s[i]-b.s[i]); if c.s[i]<0 then begin inc(c.s[i],10); dec(c.s[i+1]) end end; while(len>1) and (c.s[len]=0) do dec(len); c.len:=len end; function compare(const a,b:hp):integer;
var len:integer; begin if a.len>b.len then len:=a.len else len:=b.len; while (len>0)and(a.s[len]=b.s[len]) do dec(len); if len=0 then compare:=0 else compare:=a.s[len]-b.s[len] end; procedure multiply10(var a:hp);
var i:integer; begin for i:=a.len downto 1 do a.s[i+1]:=a.s[i]; a.s[1]:=0; inc(a.len); while (a.len>1)and(a.s[a.len]=0) do dec(a.len); end; procedure multiply(a,b:hp; var c:hp);
var i,j,x:longint; begin fillchar(c,sizeof(c),0); for i:=1 to a.len do begin x:=0; for j:=1 to b.len do begin x:=x+a.s[i]*b.s[j]+c.s[i+j-1]; c.s[i+j-1]:=x mod 10; x:=x div 10; end; c.s[i+j]:=x end; c.len:=a.len+b.len+1; while (c.s[c.len]=0)and(c.len>1) do dec(c.len) end; procedure divide(a,b:hp; var c,d:hp);
var i,j,len:integer; begin fillchar(c,sizeof(c),0); len:=a.len; fillchar(d,sizeof(d),0); d.len:=1; for i:=len downto 1 do begin multiply10(d); d.s[1]:=a.s[i]; while(compare(d,b)>=0) do begin subtract(d,b,d); inc(c.s[i]) end end; while(len>1)and(c.s[len]=0) do dec(len); c.len:=len end; function gcd(m,n:hp):hp;
var q,r:hp; begin if n.s[n.len]=0 then exit(m); divide(m,n,q,r); exit(gcd(n,r)) end; begin
init; g:=gcd(x[1],x[2]); multiply(x[1],x[2],mul); divide(mul,g,x[1],x[2]); for i:=x[1].len downto 1 do write(x[1].s[i]); writeln endconst
maxlen=500; type
hp=record len:integer; s:array[0..maxlen] of integer end; var
x:array[1..2] of hp; g,ans,mul:hp; i:longint; procedure init;
var st:string; s:array[1..2]of string; i,j:integer; begin readln(st); s[1]:=copy(st,1,pos(' ',st)-1); delete(st,1,pos(' ',st)); s[2]:=st; for j:=1 to 2 do begin x[j].len:=length(s[j]); for i:=1 to x[j].len do x[j].s[i]:=ord(s[j][x[j].len-i+1])-48 end end; procedure subtract(a,b:hp;var c:hp);
var i,len:integer; begin fillchar(c,sizeof(c),0); if a.len>b.len then len:=a.len else len:=b.len; for i:=1 to len do begin inc(c.s[i],a.s[i]-b.s[i]); if c.s[i]<0 then begin inc(c.s[i],10); dec(c.s[i+1]) end end; while(len>1) and (c.s[len]=0) do dec(len); c.len:=len end; function compare(const a,b:hp):integer;
var len:integer; begin if a.len>b.len then len:=a.len else len:=b.len; while (len>0)and(a.s[len]=b.s[len]) do dec(len); if len=0 then compare:=0 else compare:=a.s[len]-b.s[len] end; procedure multiply10(var a:hp);
var i:integer; begin for i:=a.len downto 1 do a.s[i+1]:=a.s[i]; a.s[1]:=0; inc(a.len); while (a.len>1)and(a.s[a.len]=0) do dec(a.len); end; procedure multiply(a,b:hp; var c:hp);
var i,j,x:longint; begin fillchar(c,sizeof(c),0); for i:=1 to a.len do begin x:=0; for j:=1 to b.len do begin x:=x+a.s[i]*b.s[j]+c.s[i+j-1]; c.s[i+j-1]:=x mod 10; x:=x div 10; end; c.s[i+j]:=x end; c.len:=a.len+b.len+1; while (c.s[c.len]=0)and(c.len>1) do dec(c.len) end; procedure divide(a,b:hp; var c,d:hp);
var i,j,len:integer; begin fillchar(c,sizeof(c),0); len:=a.len; fillchar(d,sizeof(d),0); d.len:=1; for i:=len downto 1 do begin multiply10(d); d.s[1]:=a.s[i]; while(compare(d,b)>=0) do begin subtract(d,b,d); inc(c.s[i]) end end; while(len>1)and(c.s[len]=0) do dec(len); c.len:=len end; function gcd(m,n:hp):hp;
var q,r:hp; begin if n.s[n.len]=0 then exit(m); divide(m,n,q,r); exit(gcd(n,r)) end; begin
init; g:=gcd(x[1],x[2]); multiply(x[1],x[2],mul); divide(mul,g,x[1],x[2]); for i:=x[1].len downto 1 do write(x[1].s[i]); writeln endconst
maxlen=500; type
hp=record len:integer; s:array[0..maxlen] of integer end; var
x:array[1..2] of hp; g,ans,mul:hp; i:longint; procedure init;
var st:string; s:array[1..2]of string; i,j:integer; begin readln(st); s[1]:=copy(st,1,pos(' ',st)-1); delete(st,1,pos(' ',st)); s[2]:=st; for j:=1 to 2 do begin x[j].len:=length(s[j]); for i:=1 to x[j].len do x[j].s[i]:=ord(s[j][x[j].len-i+1])-48 end end; procedure subtract(a,b:hp;var c:hp);
var i,len:integer; begin fillchar(c,sizeof(c),0); if a.len>b.len then len:=a.len else len:=b.len; for i:=1 to len do begin inc(c.s[i],a.s[i]-b.s[i]); if c.s[i]<0 then begin inc(c.s[i],10); dec(c.s[i+1]) end end; while(len>1) and (c.s[len]=0) do dec(len); c.len:=len end; function compare(const a,b:hp):integer;
var len:integer; begin if a.len>b.len then len:=a.len else len:=b.len; while (len>0)and(a.s[len]=b.s[len]) do dec(len); if len=0 then compare:=0 else compare:=a.s[len]-b.s[len] end; procedure multiply10(var a:hp);
var i:integer; begin for i:=a.len downto 1 do a.s[i+1]:=a.s[i]; a.s[1]:=0; inc(a.len); while (a.len>1)and(a.s[a.len]=0) do dec(a.len); end; procedure multiply(a,b:hp; var c:hp);
var i,j,x:longint; begin fillchar(c,sizeof(c),0); for i:=1 to a.len do begin x:=0; for j:=1 to b.len do begin x:=x+a.s[i]*b.s[j]+c.s[i+j-1]; c.s[i+j-1]:=x mod 10; x:=x div 10; end; c.s[i+j]:=x end; c.len:=a.len+b.len+1; while (c.s[c.len]=0)and(c.len>1) do dec(c.len) end; procedure divide(a,b:hp; var c,d:hp);
var i,j,len:integer; begin fillchar(c,sizeof(c),0); len:=a.len; fillchar(d,sizeof(d),0); d.len:=1; for i:=len downto 1 do begin multiply10(d); d.s[1]:=a.s[i]; while(compare(d,b)>=0) do begin subtract(d,b,d); inc(c.s[i]) end end; while(len>1)and(c.s[len]=0) do dec(len); c.len:=len end; function gcd(m,n:hp):hp;
var q,r:hp; begin if n.s[n.len]=0 then exit(m); divide(m,n,q,r); exit(gcd(n,r)) end; begin
init; g:=gcd(x[1],x[2]); multiply(x[1],x[2],mul); divide(mul,g,x[1],x[2]); for i:=x[1].len downto 1 do write(x[1].s[i]); writeln endconst
maxlen=500; type
hp=record len:integer; s:array[0..maxlen] of integer end; var
x:array[1..2] of hp; g,ans,mul:hp; i:longint; procedure init;
var st:string; s:array[1..2]of string; i,j:integer; begin readln(st); s[1]:=copy(st,1,pos(' ',st)-1); delete(st,1,pos(' ',st)); s[2]:=st; for j:=1 to 2 do begin x[j].len:=length(s[j]); for i:=1 to x[j].len do x[j].s[i]:=ord(s[j][x[j].len-i+1])-48 end end; procedure subtract(a,b:hp;var c:hp);
var i,len:integer; begin fillchar(c,sizeof(c),0); if a.len>b.len then len:=a.len else len:=b.len; for i:=1 to len do begin inc(c.s[i],a.s[i]-b.s[i]); if c.s[i]<0 then begin inc(c.s[i],10); dec(c.s[i+1]) end end; while(len>1) and (c.s[len]=0) do dec(len); c.len:=len end; function compare(const a,b:hp):integer;
var len:integer; begin if a.len>b.len then len:=a.len else len:=b.len; while (len>0)and(a.s[len]=b.s[len]) do dec(len); if len=0 then compare:=0 else compare:=a.s[len]-b.s[len] end; procedure multiply10(var a:hp);
var i:integer; begin for i:=a.len downto 1 do a.s[i+1]:=a.s[i]; a.s[1]:=0; inc(a.len); while (a.len>1)and(a.s[a.len]=0) do dec(a.len); end; procedure multiply(a,b:hp; var c:hp);
var i,j,x:longint; begin fillchar(c,sizeof(c),0); for i:=1 to a.len do begin x:=0; for j:=1 to b.len do begin x:=x+a.s[i]*b.s[j]+c.s[i+j-1]; c.s[i+j-1]:=x mod 10; x:=x div 10; end; c.s[i+j]:=x end; c.len:=a.len+b.len+1; while (c.s[c.len]=0)and(c.len>1) do dec(c.len) end; procedure divide(a,b:hp; var c,d:hp);
var i,j,len:integer; begin fillchar(c,sizeof(c),0); len:=a.len; fillchar(d,sizeof(d),0); d.len:=1; for i:=len downto 1 do begin multiply10(d); d.s[1]:=a.s[i]; while(compare(d,b)>=0) do begin subtract(d,b,d); inc(c.s[i]) end end; while(len>1)and(c.s[len]=0) do dec(len); c.len:=len end; function gcd(m,n:hp):hp;
var q,r:hp; begin if n.s[n.len]=0 then exit(m); divide(m,n,q,r); exit(gcd(n,r)) end; begin
init; g:=gcd(x[1],x[2]); multiply(x[1],x[2],mul); divide(mul,g,x[1],x[2]); for i:=x[1].len downto 1 do write(x[1].s[i]); writeln endvconst
maxlen=500; type
hp=record len:integer; s:array[0..maxlen] of integer end; var
x:array[1..2] of hp; g,ans,mul:hp; i:longint; procedure init;
var st:string; s:array[1..2]of string; i,j:integer; begin readln(st); s[1]:=copy(st,1,pos(' ',st)-1); delete(st,1,pos(' ',st)); s[2]:=st; for j:=1 to 2 do begin x[j].len:=length(s[j]); for i:=1 to x[j].len do x[j].s[i]:=ord(s[j][x[j].len-i+1])-48 end end; procedure subtract(a,b:hp;var c:hp);
var i,len:integer; begin fillchar(c,sizeof(c),0); if a.len>b.len then len:=a.len else len:=b.len; for i:=1 to len do begin inc(c.s[i],a.s[i]-b.s[i]); if c.s[i]<0 then begin inc(c.s[i],10); dec(c.s[i+1]) end end; while(len>1) and (c.s[len]=0) do dec(len); c.len:=len end; function compare(const a,b:hp):integer;
var len:integer; begin if a.len>b.len then len:=a.len else len:=b.len; while (len>0)and(a.s[len]=b.s[len]) do dec(len); if len=0 then compare:=0 else compare:=a.s[len]-b.s[len] end; procedure multiply10(var a:hp);
var i:integer; begin for i:=a.len downto 1 do a.s[i+1]:=a.s[i]; a.s[1]:=0; inc(a.len); while (a.len>1)and(a.s[a.len]=0) do dec(a.len); end; procedure multiply(a,b:hp; var c:hp);
var i,j,x:longint; begin fillchar(c,sizeof(c),0); for i:=1 to a.len do begin x:=0; for j:=1 to b.len do begin x:=x+a.s[i]*b.s[j]+c.s[i+j-1]; c.s[i+j-1]:=x mod 10; x:=x div 10; end; c.s[i+j]:=x end; c.len:=a.len+b.len+1; while (c.s[c.len]=0)and(c.len>1) do dec(c.len) end; procedure divide(a,b:hp; var c,d:hp);
var i,j,len:integer; begin fillchar(c,sizeof(c),0); len:=a.len; fillchar(d,sizeof(d),0); d.len:=1; for i:=len downto 1 do begin multiply10(d); d.s[1]:=a.s[i]; while(compare(d,b)>=0) do begin subtract(d,b,d); inc(c.s[i]) end end; while(len>1)and(c.s[len]=0) do dec(len); c.len:=len end; function gcd(m,n:hp):hp;
var q,r:hp; begin if n.s[n.len]=0 then exit(m); divide(m,n,q,r); exit(gcd(n,r)) end; begin
init; g:=gcd(x[1],x[2]); multiply(x[1],x[2],mul); divide(mul,g,x[1],x[2]); for i:=x[1].len downto 1 do write(x[1].s[i]); writeln endconst
maxlen=500; type
hp=record len:integer; s:array[0..maxlen] of integer end; var
x:array[1..2] of hp; g,ans,mul:hp; i:longint; procedure init;
var st:string; s:array[1..2]of string; i,j:integer; begin readln(st); s[1]:=copy(st,1,pos(' ',st)-1); delete(st,1,pos(' ',st)); s[2]:=st; for j:=1 to 2 do begin x[j].len:=length(s[j]); for i:=1 to x[j].len do x[j].s[i]:=ord(s[j][x[j].len-i+1])-48 end end; procedure subtract(a,b:hp;var c:hp);
var i,len:integer; begin fillchar(c,sizeof(c),0); if a.len>b.len then len:=a.len else len:=b.len; for i:=1 to len do begin inc(c.s[i],a.s[i]-b.s[i]); if c.s[i]<0 then begin inc(c.s[i],10); dec(c.s[i+1]) end end; while(len>1) and (c.s[len]=0) do dec(len); c.len:=len end; function compare(const a,b:hp):integer;
var len:integer; begin if a.len>b.len then len:=a.len else len:=b.len; while (len>0)and(a.s[len]=b.s[len]) do dec(len); if len=0 then compare:=0 else compare:=a.s[len]-b.s[len] end; procedure multiply10(var a:hp);
var i:integer; begin for i:=a.len downto 1 do a.s[i+1]:=a.s[i]; a.s[1]:=0; inc(a.len); while (a.len>1)and(a.s[a.len]=0) do dec(a.len); end; procedure multiply(a,b:hp; var c:hp);
var i,j,x:longint; begin fillchar(c,sizeof(c),0); for i:=1 to a.len do begin x:=0; for j:=1 to b.len do begin x:=x+a.s[i]*b.s[j]+c.s[i+j-1]; c.s[i+j-1]:=x mod 10; x:=x div 10; end; c.s[i+j]:=x end; c.len:=a.len+b.len+1; while (c.s[c.len]=0)and(c.len>1) do dec(c.len) end; procedure divide(a,b:hp; var c,d:hp);
var i,j,len:integer; begin fillchar(c,sizeof(c),0); len:=a.len; fillchar(d,sizeof(d),0); d.len:=1; for i:=len downto 1 do begin multiply10(d); d.s[1]:=a.s[i]; while(compare(d,b)>=0) do begin subtract(d,b,d); inc(c.s[i]) end end; while(len>1)and(c.s[len]=0) do dec(len); c.len:=len end; function gcd(m,n:hp):hp;
var q,r:hp; begin if n.s[n.len]=0 then exit(m); divide(m,n,q,r); exit(gcd(n,r)) end; begin
init; g:=gcd(x[1],x[2]); multiply(x[1],x[2],mul); divide(mul,g,x[1],x[2]); for i:=x[1].len downto 1 do write(x[1].s[i]); writeln endconst
maxlen=500; type
hp=record len:integer; s:array[0..maxlen] of integer end; var
x:array[1..2] of hp; g,ans,mul:hp; i:longint; procedure init;
var st:string; s:array[1..2]of string; i,j:integer; begin readln(st); s[1]:=copy(st,1,pos(' ',st)-1); delete(st,1,pos(' ',st)); s[2]:=st; for j:=1 to 2 do begin x[j].len:=length(s[j]); for i:=1 to x[j].len do x[j].s[i]:=ord(s[j][x[j].len-i+1])-48 end end; procedure subtract(a,b:hp;var c:hp);
var i,len:integer; begin fillchar(c,sizeof(c),0); if a.len>b.len then len:=a.len else len:=b.len; for i:=1 to len do begin inc(c.s[i],a.s[i]-b.s[i]); if c.s[i]<0 then begin inc(c.s[i],10); dec(c.s[i+1]) end end; while(len>1) and (c.s[len]=0) do dec(len); c.len:=len end; function compare(const a,b:hp):integer;
var len:integer; begin if a.len>b.len then len:=a.len else len:=b.len; while (len>0)and(a.s[len]=b.s[len]) do dec(len); if len=0 then compare:=0 else compare:=a.s[len]-b.s[len] end; procedure multiply10(var a:hp);
var i:integer; begin for i:=a.len downto 1 do a.s[i+1]:=a.s[i]; a.s[1]:=0; inc(a.len); while (a.len>1)and(a.s[a.len]=0) do dec(a.len); end; procedure multiply(a,b:hp; var c:hp);
var i,j,x:longint; begin fillchar(c,sizeof(c),0); for i:=1 to a.len do begin x:=0; for j:=1 to b.len do begin x:=x+a.s[i]*b.s[j]+c.s[i+j-1]; c.s[i+j-1]:=x mod 10; x:=x div 10; end; c.s[i+j]:=x end; c.len:=a.len+b.len+1; while (c.s[c.len]=0)and(c.len>1) do dec(c.len) end; procedure divide(a,b:hp; var c,d:hp);
var i,j,len:integer; begin fillchar(c,sizeof(c),0); len:=a.len; fillchar(d,sizeof(d),0); d.len:=1; for i:=len downto 1 do begin multiply10(d); d.s[1]:=a.s[i]; while(compare(d,b)>=0) do begin subtract(d,b,d); inc(c.s[i]) end end; while(len>1)and(c.s[len]=0) do dec(len); c.len:=len end; function gcd(m,n:hp):hp;
var q,r:hp; begin if n.s[n.len]=0 then exit(m); divide(m,n,q,r); exit(gcd(n,r)) end; begin
init; g:=gcd(x[1],x[2]); multiply(x[1],x[2],mul); divide(mul,g,x[1],x[2]); for i:=x[1].len downto 1 do write(x[1].s[i]); writeln endconst
maxlen=500; type
hp=record len:integer; s:array[0..maxlen] of integer end; var
x:array[1..2] of hp; g,ans,mul:hp; i:longint; procedure init;
var st:string; s:array[1..2]of string; i,j:integer; begin readln(st); s[1]:=copy(st,1,pos(' ',st)-1); delete(st,1,pos(' ',st)); s[2]:=st; for j:=1 to 2 do begin x[j].len:=length(s[j]); for i:=1 to x[j].len do x[j].s[i]:=ord(s[j][x[j].len-i+1])-48 end end; procedure subtract(a,b:hp;var c:hp);
var i,len:integer; begin fillchar(c,sizeof(c),0); if a.len>b.len then len:=a.len else len:=b.len; for i:=1 to len do begin inc(c.s[i],a.s[i]-b.s[i]); if c.s[i]<0 then begin inc(c.s[i],10); dec(c.s[i+1]) end end; while(len>1) and (c.s[len]=0) do dec(len); c.len:=len end; function compare(const a,b:hp):integer;
var len:integer; begin if a.len>b.len then len:=a.len else len:=b.len; while (len>0)and(a.s[len]=b.s[len]) do dec(len); if len=0 then compare:=0 else compare:=a.s[len]-b.s[len] end; procedure multiply10(var a:hp);
var i:integer; begin for i:=a.len downto 1 do a.s[i+1]:=a.s[i]; a.s[1]:=0; inc(a.len); while (a.len>1)and(a.s[a.len]=0) do dec(a.len); end; procedure multiply(a,b:hp; var c:hp);
var i,j,x:longint; begin fillchar(c,sizeof(c),0); for i:=1 to a.len do begin x:=0; for j:=1 to b.len do begin x:=x+a.s[i]*b.s[j]+c.s[i+j-1]; c.s[i+j-1]:=x mod 10; x:=x div 10; end; c.s[i+j]:=x end; c.len:=a.len+b.len+1; while (c.s[c.len]=0)and(c.len>1) do dec(c.len) end; procedure divide(a,b:hp; var c,d:hp);
var i,j,len:integer; begin fillchar(c,sizeof(c),0); len:=a.len; fillchar(d,sizeof(d),0); d.len:=1; for i:=len downto 1 do begin multiply10(d); d.s[1]:=a.s[i]; while(compare(d,b)>=0) do begin subtract(d,b,d); inc(c.s[i]) end end; while(len>1)and(c.s[len]=0) do dec(len); c.len:=len end; function gcd(m,n:hp):hp;
var q,r:hp; begin if n.s[n.len]=0 then exit(m); divide(m,n,q,r); exit(gcd(n,r)) end; begin
init; g:=gcd(x[1],x[2]); multiply(x[1],x[2],mul); divide(mul,g,x[1],x[2]); for i:=x[1].len downto 1 do write(x[1].s[i]); writeln endconst
maxlen=500; type
hp=record len:integer; s:array[0..maxlen] of integer end; var
x:array[1..2] of hp; g,ans,mul:hp; i:longint; procedure init;
var st:string; s:array[1..2]of string; i,j:integer; begin readln(st); s[1]:=copy(st,1,pos(' ',st)-1); delete(st,1,pos(' ',st)); s[2]:=st; for j:=1 to 2 do begin x[j].len:=length(s[j]); for i:=1 to x[j].len do x[j].s[i]:=ord(s[j][x[j].len-i+1])-48 end end; procedure subtract(a,b:hp;var c:hp);
var i,len:integer; begin fillchar(c,sizeof(c),0); if a.len>b.len then len:=a.len else len:=b.len; for i:=1 to len do begin inc(c.s[i],a.s[i]-b.s[i]); if c.s[i]<0 then begin inc(c.s[i],10); dec(c.s[i+1]) end end; while(len>1) and (c.s[len]=0) do dec(len); c.len:=len end; function compare(const a,b:hp):integer;
var len:integer; begin if a.len>b.len then len:=a.len else len:=b.len; while (len>0)and(a.s[len]=b.s[len]) do dec(len); if len=0 then compare:=0 else compare:=a.s[len]-b.s[len] end; procedure multiply10(var a:hp);
var i:integer; begin for i:=a.len downto 1 do a.s[i+1]:=a.s[i]; a.s[1]:=0; inc(a.len); while (a.len>1)and(a.s[a.len]=0) do dec(a.len); end; procedure multiply(a,b:hp; var c:hp);
var i,j,x:longint; begin fillchar(c,sizeof(c),0); for i:=1 to a.len do begin x:=0; for j:=1 to b.len do begin x:=x+a.s[i]*b.s[j]+c.s[i+j-1]; c.s[i+j-1]:=x mod 10; x:=x div 10; end; c.s[i+j]:=x end; c.len:=a.len+b.len+1; while (c.s[c.len]=0)and(c.len>1) do dec(c.len) end; procedure divide(a,b:hp; var c,d:hp);
var i,j,len:integer; begin fillchar(c,sizeof(c),0); len:=a.len; fillchar(d,sizeof(d),0); d.len:=1; for i:=len downto 1 do begin multiply10(d); d.s[1]:=a.s[i]; while(compare(d,b)>=0) do begin subtract(d,b,d); inc(c.s[i]) end end; while(len>1)and(c.s[len]=0) do dec(len); c.len:=len end; function gcd(m,n:hp):hp;
var q,r:hp; begin if n.s[n.len]=0 then exit(m); divide(m,n,q,r); exit(gcd(n,r)) end; begin
init; g:=gcd(x[1],x[2]); multiply(x[1],x[2],mul); divide(mul,g,x[1],x[2]); for i:=x[1].len downto 1 do write(x[1].s[i]); writeln endvconst
maxlen=500; type
hp=record len:integer; s:array[0..maxlen] of integer end; var
x:array[1..2] of hp; g,ans,mul:hp; i:longint; procedure init;
var st:string; s:array[1..2]of string; i,j:integer; begin readln(st); s[1]:=copy(st,1,pos(' ',st)-1); delete(st,1,pos(' ',st)); s[2]:=st; for j:=1 to 2 do begin x[j].len:=length(s[j]); for i:=1 to x[j].len do x[j].s[i]:=ord(s[j][x[j].len-i+1])-48 end end; procedure subtract(a,b:hp;var c:hp);
var i,len:integer; begin fillchar(c,sizeof(c),0); if a.len>b.len then len:=a.len else len:=b.len; for i:=1 to len do begin inc(c.s[i],a.s[i]-b.s[i]); if c.s[i]<0 then begin inc(c.s[i],10); dec(c.s[i+1]) end end; while(len>1) and (c.s[len]=0) do dec(len); c.len:=len end; function compare(const a,b:hp):integer;
var len:integer; begin if a.len>b.len then len:=a.len else len:=b.len; while (len>0)and(a.s[len]=b.s[len]) do dec(len); if len=0 then compare:=0 else compare:=a.s[len]-b.s[len] end; procedure multiply10(var a:hp);
var i:integer; begin for i:=a.len downto 1 do a.s[i+1]:=a.s[i]; a.s[1]:=0; inc(a.len); while (a.len>1)and(a.s[a.len]=0) do dec(a.len); end; procedure multiply(a,b:hp; var c:hp);
var i,j,x:longint; begin fillchar(c,sizeof(c),0); for i:=1 to a.len do begin x:=0; for j:=1 to b.len do begin x:=x+a.s[i]*b.s[j]+c.s[i+j-1]; c.s[i+j-1]:=x mod 10; x:=x div 10; end; c.s[i+j]:=x end; c.len:=a.len+b.len+1; while (c.s[c.len]=0)and(c.len>1) do dec(c.len) end; procedure divide(a,b:hp; var c,d:hp);
var i,j,len:integer; begin fillchar(c,sizeof(c),0); len:=a.len; fillchar(d,sizeof(d),0); d.len:=1; for i:=len downto 1 do begin multiply10(d); d.s[1]:=a.s[i]; while(compare(d,b)>=0) do begin subtract(d,b,d); inc(c.s[i]) end end; while(len>1)and(c.s[len]=0) do dec(len); c.len:=len end; function gcd(m,n:hp):hp;
var q,r:hp; begin if n.s[n.len]=0 then exit(m); divide(m,n,q,r); exit(gcd(n,r)) end; begin
init; g:=gcd(x[1],x[2]); multiply(x[1],x[2],mul); divide(mul,g,x[1],x[2]); for i:=x[1].len downto 1 do write(x[1].s[i]); writeln end -
-12015-11-21 14:40:19@
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>using namespace std;
int main()
{
int m,n,k=0,p;
cin >> m >> n;
p = min (m , n);
for (int i = 1 ;i <= p ;i++)
if (m % i == 0 && n % i == 0)
k = i;
cout << m*n/k<<endl;
system("pause");
return 0;
}