13分求助
查看原帖
13分求助
1286983
HangingMirror楼主2024/6/9 14:55

13分求助!谢谢。

#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        int a,b,c,g;
        cin>>a>>b>>c;
        g=__gcd(b,a);
        b/=g,a/=g;
        if(a<b){
            cout<<b*ceil((double)c/a)+a*ceil((double)c/a)<<endl;
        }else cout<<b*ceil((double)c/b)+a*ceil((double)c/b)<<endl;
    }
}
2024/6/9 14:55
加载中...