1 条题解

  • 0
    @ 2025-4-14 18:43:49

    C++ :

    #include <cstdio>
    #include <algorithm>
    #include <iostream>
    #include <fstream>
    using namespace std;
    
    int gcd(int a,int b){
        if(b==0) return a;
        else return gcd(b,a%b);
    }
    int main(){
        int a,b,x,y,g;
    //    ifstream cin;
    //    ofstream cout;
    //    cin.open("h.in");
    //    cout.open("h.out");
        int testcase;
        cin>>testcase;
        while(testcase--)
        {
        cin>>a>>b>>x>>y;
        g=gcd(x,y);
        x/=g;
        y/=g;
        g=std::min(a/x,b/y);
        cout<<x*g<<" "<<y*g<<endl;
    	}
       return 0;
    }
    
    
    • 1

    信息

    ID
    3375
    时间
    1000ms
    内存
    256MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者