标签:cti ase opened amp close return sof span typedef
water
//#define test #include<bits/stdc++.h> using namespace std; const int Nmax=1e6+7; typedef long long ll; struct LL { ll a,b; LL(){ } LL(ll aa,ll bb){ a=aa,b=bb; ll g=__gcd(a,b); a/=g; b/=g; } friend LL operator + (const LL &a,const LL &b) { ll t2=a.b*b.b, t1=a.a*b.b+a.b*b.a; return LL(t1,t2); } friend LL operator + (const ll &a,const LL &b) { ll t1=a*b.b+b.a; return LL(t1,b.b); } friend LL operator / (const ll &a,const LL &b) { return LL(a*b.b,b.a); } }; int n; ll a[Nmax],b[Nmax]; int main() { #ifdef test #endif int t; //freopen("b.in","r",stdin); scanf("%d",&t); for(int _=1;_<=t;_++) { LL ans(0,1); scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%lld",&a[i]); } for(int i=1;i<=n;i++) scanf("%lld",&b[i]); for(int i=n;i>=1;i--) { ans=b[i]/(a[i]+ans); } printf("Case #%d: ",_); printf("%lld %lld\n",ans.a,ans.b); } return 0; }
CCPC2016长春B (hdu 5912 Fraction)
标签:cti ase opened amp close return sof span typedef
原文地址:https://www.cnblogs.com/LMissher/p/9673981.html