关于在电脑上全对但是测评WA的问题
查看原帖
关于在电脑上全对但是测评WA的问题
481079
Yanshi_0233楼主2022/11/30 14:15

在自己的电脑上无论测评什么数,都会全对,但是结果还是WA

#include <iostream>
using namespace std;

int x,y,big;
int fractionReduction(int a,int b){
	x=a,y=b,big=(a>b?a:b);
	for(int i=big;i>=1;i--){
		if(x%i==0&&y%i==0){
			x/=i; y/=i;
		}
	} 
}

int main(){
	int n;
	cin>>n;
	int t,p,o=0;
	int t1,p1,o1;
	for(int i=0;i<n;i++) {
		cin>>t1>>p1>>o1;
		if(o1==1) {
			fractionReduction(t*p1+p*t1,p*p1);
			t=x; p=y;
		} else {
			fractionReduction(t*p1-p*t1,p*p1);
			t=x; p=y;
		}
	}
	if(p!=1) {
		cout<<t<<"/"<<p;
	} else {
		cout<<t;
	}
	return 0;
} 

求助大佬

2022/11/30 14:15
加载中...