1 条题解

  • 0
    @ 2024-8-2 16:19:45

    C++ :

    #include <bits/stdc++.h>
    using namespace std;
    
    int x, y;
    char c;
    
    int main() {
        cin >> x >> c >> y;
    
        // Find the greatest common divisor
        int a = x, b = y, t;
        while (b != 0) {
            t = a % b;
            a = b;
            b = t;
        }
    
        // Reduce the fraction
        cout << x / a << ":" << y / a << endl;
    
        return 0;
    }
    
    

    信息

    ID
    1026
    时间
    1000ms
    内存
    128MiB
    难度
    10
    标签
    递交数
    3
    已通过
    3
    上传者