怎么没人回我(急)
#include<bits/stdc++.h>
using namespace std;
int n;
long long fm=1,fz=0;
inline int gcd(int x,int y) { return y==0?x:gcd(y,x%y); }
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
{
long long a,b,opt;
cin>>a>>b>>opt;
if(opt==1) fz=fz*b+fm*a;
else fz=fz*b-fm*a;
fm*=b;
int ______gcd______=gcd(fm,fz);
fm/=______gcd______;
fz/=______gcd______;
}
if(fm==fz) cout<<"1";
else if(fz==0) cout<<"0";
else if(fm==1) cout<<fz;
else if(fm<0) cout<<-fz<<"/"<<-fm;
else cout<<fz<<"/"<<fm;
return 0;
}
WA记录