样例过了但是全RE
查看原帖
样例过了但是全RE
1247655
111111lcr楼主2024/6/12 21:38
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
	if(a<b) swap(a,b);
	if(a%b==0) return b;
	gcd(b,a%b);
}
int main(){
	int t;
	cin>>t;
	for(int i=1;i<=t;i++){
		int a,b,c,cnt,s,x;
		cin>>a>>b>>c;
		cnt=gcd(a,b);
		a/=cnt,b/=cnt;
		x=min(a,b);
		cnt=c-x;
		s=cnt/x;
		if(cnt%x==0) s++;
		else s+=2;
		cout<<(a+b)*s<<"\n";
	}
	return 0;
}

样例过了但是全RE,何哉??

2024/6/12 21:38
加载中...