#include<bits/stdc++.h>
#define LL long long
using namespace std;
inline LL read(){
int x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9'){
if(ch=='-') f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9'){
x=(x<<1)+(x<<3)+(ch^48);
ch=getchar();
}
return x*f;
}
LL gcd(LL a,LL b){
if(b==0) return a;
return gcd(b,a%b);
}
int main(){
// freopen("P8584.in","r",stdin);
// freopen("P8584.out","w",stdout);
LL n=read(),zi=0,mu=1;
for(LL i=1;i<=n;i++){
LL a=read(),b=read(),op=read();
if(op==1){
LL tmp=b;
a*=mu,b*=mu;
zi*=tmp,mu*=tmp;
zi+=a;
if(zi%mu==0)
if(zi>mu){
zi/=mu;
mu=1;
}
}
if(op==2){
LL tmp=b;
a*=mu,b*=mu;
zi*=tmp,mu*=tmp;
zi-=a;
if(zi%mu==0)
if(zi>mu){
zi/=mu;
mu=1;
}
}
}
LL g=gcd(zi,mu);
zi/=g,mu/=g;
if(mu==1) printf("%lld",zi);
else if(mu>0)printf("%lld/%lld",zi,mu);
else printf("%lld/%lld",-zi,-mu);
// fclose(stdin);fclose(stdout);
return 0;
}
样例全过,提交RE了7个点