#include<iostream>
#include<algorithm>
using namespace std;
struct Fraction{
long long up,down;
};
int (int a,int b)
{
if(a<b) swap(a,b);
if(b==0) return a;
else return (b,a%b);
}
Fraction reduction(Fraction a)
{
if(a.down<0){
a.up=-a.up;
a.down=-a.down;
}
if(a.up==0) a.down=1;
else{
int d=(abs(a.up),abs(a.down));
a.up/=d;
a.down/=d;
}
return a;
}
Fraction add(Fraction a,Fraction b)
{
Fraction ans;
ans.up=a.up*b.down+b.up*a.down;
ans.down=a.down*b.down;
return reduction(ans);
}
void show(Fraction a)
{
if(a.down==1) printf("%d\n",a.up);
else if(abs(a.up)>a.down){
printf("%d %d/%d\n",a.up/a.down,abs(a.up)%a.down,a.down);
}else{
printf("%d/%d\n",a.up,a.down);
}
}
int main()
{
int n;
Fraction ans={0,1},temp;
cin>>n;
for(int i=0;i<n;i++){
scanf("%lld/%lld",&temp.up,&temp.down);
ans=add(ans,temp);
}
show(ans);
return 0;
}
本地错了oj对了… code blocks dev-c++ 什么的就是这么玄学 习惯了习惯了