This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
#include<bits/stdc++.h>
using namespace std;
//自定义一个求最大公因数的函数,用来约分(辗转相除法)(这里用到了一个三目运算符)
int gcd(int a, int b) {
return b == 0 ? a : gcd(b, a % b);
}
int main() {
int a, b, x, y, s;//s为新分数分子和分母的最大公因数
char m, n;//m,n为输入的两个“/”
cin >> a >> m >> b;
cin >> x >> n >> y;
x *= a;
y *= b;
s = gcd(x, y);//x为新分子,y为新分母,s为最大公因数
x /= s;
y /= s;//约分
cout << y << " " << x;//输出第y列,第x行(顺序不能写反,否则只有20分)
return 0;