ll gcd(ll a,ll b) { if(b==0) { return a; }else { return gcd(b,a%b); } } ll ABS(ll x) { return x<0 ? -x : x; } struct F { ll num,den;// fenzi -> num fenmu-> den F(ll num=0,ll den=1) { if(den<0) num=-num,den=-den; ll g = gcd(ABS(num),den); this->num = num/g; this->den = den/g; } F operator+(const F &o)const { return F(num*o.den + den*o.num, den*o.den); } F operator*(const F &o)const { return F(num*o.num , den*o.den); } F operator/(const F &o) const { return F(num*o.den,den*o.num); } };
原文地址:https://www.cnblogs.com/qieqiemin/p/10290212.html
时间: 2024-10-07 14:33:33