3 条题解
-
1240810cj杨宇诚 (杨宇诚) LV 8 @ 2024-08-07 10:08:06
#include<iostream>
using namespace std;
long long gcd(long long a, long long b){
if(a < b)swap(a, b);
if(a % b == 0)return b;
while(true){
a = a % b;
if(b % a == 0)return a;
b = b % a;
if(a % b == 0)return b;
}
}
int main(){
long long a, b, c, d;
cin >> a >> b >> c >> d;
a = a*d + b*c;
b = b*d;
long long gcd1 = gcd(a, b);
cout << a/gcd1 << " " << b/gcd1;
return 0;
}//541881314 -
02024-06-29 13:33:43@
#include<iostream> using namespace std; long long gcd(long long a, long long b){ if(a < b)swap(a, b); if(a % b == 0)return b; while(true){ a = a % b; if(b % a == 0)return a; b = b % a; if(a % b == 0)return b; } } int main(){ long long a, b, c, d; cin >> a >> b >> c >> d; a = a*d + b*c; b = b*d; long long gcd1 = gcd(a, b); cout << a/gcd1 << " " << b/gcd1; return 0; }
-
02022-01-14 10:37:42@
#include<bits/stdc++.h> using namespace std; int main() { int b1, a1, a2, b2, a3, b3, aa3,bb3; cin>>b1; cin>>a1; cin>>b2; cin>>a2; int aa1=a1, aa2=a2; while( 1 ) //两分母最大公因数 { a3=aa1%aa2; if(a3==0) break; aa1=aa2; aa2=a3; } b3=a1/aa2*a2;//最小公倍数 b1=b3/a1*b1;//b1分子扩大 b2=b3/a2*b2;//b2分子扩大 bb3=b1+b2;//b1+b2 int bb1=b3, bb2=bb3;//化简 while( 1 ) //分子、分母最大公因数 { aa3=bb1%bb2; if(aa3==0) break; bb1=bb2; bb2=aa3; } b1=bb3/bb2;//分子化简 b2=b3/bb2;//分母化简 cout<<b1<<" "<<b2<<endl; return 0; }
- 1
信息
- ID
- 1063
- 难度
- 3
- 分类
- (无)
- 标签
- 递交数
- 141
- 已通过
- 69
- 通过率
- 49%
- 上传者