題目描述
求2-a+2-b,其中a和b均爲正整數,結果請用最簡分數表示。
輸入格式
第一行爲測試數據的組數T(1<=T<=400)。請注意,任意兩組測試數據之間是相互獨立的。
每組測試數據一行,包含兩個整數a和b(2<=a,b<=20)。
輸出格式
對於每組測試數據,在一行內輸出結果,分子和分母用“/”隔開。
輸入樣例
2
2 4
3 2
輸出樣例
5/16
3/8
#include <cstdio>
#include <cmath>
using namespace std;
int main(){
int a,b;
int up,down;
int t;
scanf("%d",&t);
for (int time=0;time<t;time++){
//input
scanf("%d%d",&a,&b);
if (a<b){//大的在前
int temp=a;
a=b;
b=temp;
}
//process
up=pow(2,a-b)+1;
down=pow(2,a);
while (up%2==0){
up/=2;
down/=2;
}
//output
printf("%d/%d\n",up,down);
}
return true;
}