problem statement is here
#include<stdio.h>
long long gcd(long long a,long long b){
if(b==0){
return a;
}
return gcd(b,a%b);
}
int main(){
long long a,b,c,d,e,f,g,i,j,cc=1,t;
scanf("%lld",&t);
while(t--){
scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
e=a*(c+1)+b*(d+1);
f=(a+b)*(c+1+d);
g=gcd(e,f);
if(g>0){
e/=g;
f/=g;
}
if(e==0){
printf("Case %lld: 0\n",cc);
}else{
printf("Case %lld: %lld/%lld\n",cc,e,f);
}
cc++;
}
return 0;
}
No comments:
Post a Comment