UVA 11971 Polygon
#include<bits/stdc++.h>
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<algorithm>
#include<stack>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b)
{
return b==0?a:gcd(b,a%b);
}
ll mypow(int a,int b)
{
ll res=1;
while(b--)res*=a;
return res;
}
//分数类
struct Fraction{
long long num;
long long den;
Fraction(long long num=0,long long den=1){
if(den<0){
num=-num;
den=-den;
}
assert(den!=0);
long long g=gcd(abs(num),den);
this->num=num/g;
this->den=den/g;
}
Fraction operator+(const Fraction&o)const {
return Fraction(num*o.den+den*o.num,den*o.den);
}
Fraction operator-(const Fraction&o)const{
return Fraction(num*o.den-den*o.num,den*o.den);
}
Fraction operator*(const Fraction &o)const{
return Fraction(num*o.num,den*o.den);
}
Fraction operator/(const Fraction&o)const{
return Fraction(num*o.den,den*o.num);
}
bool operator<(const Fraction &o)const{
return num*o.den<den*o.num;
}
bool operator==(const Fraction&o)const{
return num*o.den==den*o.num;
}
};
int id=1;
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif // ONLIN
int t;int n,k;
cin>>t;
Fraction f1(1,1);
while(t--)
{
cin>>n>>k;
Fraction f(k+1,mypow(2,k));
Fraction ans;
ans=f1-f;
cout<<"Case #"<<id++<<": ";
cout<<ans.num<<"/"<<ans.den<<endl;
}
}