4 条题解
-
412239姚与露 (12239姚与露) LV 7 @ 2021-12-31 15:54:25
#include<iostream>
using namespace std;
int main()
{
int m,n,r;
cin>>m>>n;
r=m%n;
int mm=m,nn=n;
while(r!=0)
{
mm=nn;
nn=r;
r=mm%nn;
}
cout<<nn<<endl;
cout<<m/nn*n<<endl;
return 0;
} -
22022-06-21 10:46:43@
#include<iostream>
using namespace std;
int main()
{
int m,n,r;
cin>>m>>n;
r=m%n;
int mm=m,nn=n;
while(r!=0)
{
mm=nn;
nn=r;
r=mm%nn;
}
cout<<nn<<endl;
cout<<m/nn*n<<endl;
return 0;
} -
12024-05-24 22:23:19@
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
if(a%b==0) return b;
return gcd(b,a%b);
}
int lcm(long c,long d){
for(int i=10000000;i>=0;i--)
if(c%i==0&&d%i==0)
return (c*d)/i;
}
int main(){
int a,b;
cin>>a>>b;
cout<<gcd(a,b)<<endl<<lcm(a,b)<<endl;
return 0;
} -
02021-12-25 11:01:15@
#include<iostream> using namespace std; int main() { int a,b; cin>>a>>b; int aa=a,bb=b,cc=aa%bb; while(cc) { aa=bb; bb=cc; cc=aa%bb; } cout<<bb<<"\n"<<a/bb*b; return 0; }
- 1
信息
- ID
- 1062
- 难度
- 5
- 分类
- (无)
- 标签
- 递交数
- 329
- 已通过
- 117
- 通过率
- 36%
- 上传者