中级天翼
#include<iostream>
#include<string>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<iomanip>
using namespace std;
int gcd(int n,int m){
if(m==0){
return n;
}
return gcd(m,n%m);
}
int main(){
int a1,a2,b1,b2;
cin>>a1>>a2>>b1>>b2;
cout<<a1*b1/gcd(a1*b1,a2*b2)<<'/'<<a2*b2/gcd(a1*b1,a2*b2);
return 0;
}
黄子澄在2020-08-05 19:23:59追加了内容
#include<iostream>
#include<string>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<iomanip>
using namespace std;
int gcd(int n,int m){
if(m==0){
return n;
}
return gcd(m,n%m);
}
int main(){
int a1,a2,b1,b2,c1,c2;
cin>>a1>>a2>>b1>>b2;
c1=a1*b1/gcd(a1*b1,a2*b2);
c2=a2*b2/gcd(a1*b1,a2*b2);
if(c2==1){
cout<<c1;
}
else{
cout<<c1<<"/"<<c2;
}
return 0;
}