其他分享
首页 > 其他分享> > 选拔赛c题武器大师的宝贝

选拔赛c题武器大师的宝贝

作者:互联网

#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
typedef long long ll;
ll getshu(ll a,ll c)
{
    while(1)
    {if(c%a==0)
        {return a;break;}
        ll tep=c;
        c=a;
        a=tep%a;}
}
int main()
{
    int t;
cin>>t;
while(t--)
{
    ll fl,fr,sl,sr;
    cin>>fl>>fr>>sl>>sr;
    ll ans=0;
    if(fr<sl||sr<fl)cout<<"0/1"<<endl;
   else
   {
        if(fl<=sl&&fr>=sl)
   {
       if(fr<=sr)ans+=fr-sl+1;
       else ans+=sr-sl+1;
   }
   if(sl<fl&&sr>=fl)
   {
       if(sr<=fr)ans+=sr-fl+1;
       else ans+=fr-fl+1;
   }
        ll f1=fr-fl+1,f2=sr-sl+1;
        ll fz=f1*f2;
        ll chu=getshu(ans,fz);
        cout<<ans/chu<<"/"<<fz/chu<<endl;
   }
}
}

标签:fr,宝贝,sr,ll,选拔赛,sl,include,fl,大师
来源: https://blog.csdn.net/weixin_43331783/article/details/88362615