题目描述

求2^-a + 2^-b,其中a和b均为正整数,结果用最简分数表示

输入

第一行为测试数据的组数T (1~400)。请注意,任意两组测试数据之间相互独立的。
每组测试数据一行,包含两个整数a和b (2~20)。

 

输出

对于每组测试数据,输出结果。

样例输入

2
2 4
3 2

样例输出

5/16
3/8

来源

2014网研A题

#include<algorithm>
#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;
struct donser
{
ll son;
ll mother;
};
int main()
{
ll a;
while(~scanf("%d",&a))
{
while(a--)
{
ll x,y;
cin>>x>>y;
donser m,n;
m.mother=m.son=;
n.mother=n.son=;
while(x--)
m.mother*=;
while(y--)
n.mother*=;
ll temp=m.mother*n.mother;
m.son=n.mother;
n.son=m.mother;
n.son=n.son+m.son;
n.mother=temp;
for(ll i=n.son;i>;i--)
{
if(n.mother%i==&&n.son%i==)
{
n.mother/=i;
n.son/=i;
}
}
cout<<n.son<<"/"<<n.mother<<endl;
}
}
return ;
}

最新文章

  1. assert_option()可以用来对assert()进行一些约束和控制
  2. Qt5 新特性
  3. js里面的 InttoStr 和 StrtoInt
  4. jsp-avaBean
  5. Object转换为json格式
  6. CommonJS规范
  7. Android实现网络多线程文件下载
  8. phpexcel来做表格导出(多个工作sheet)
  9. Android 自定义对话框(Dialog)位置,大小
  10. 动画——animation部分
  11. 如何计算Java对象所占内存的大小
  12. C语言中getch()、getche()和getchar()
  13. ios开发之--valueForKeyPath的用法
  14. Linux基础笔记—— 走进Linux
  15. 设置获取cookie,setCookie,getCookie
  16. 【BZOJ3489】A simple rmq problem(KD-Tree)
  17. Cmake编译SDL2
  18. Jackson Gson Json.simple part 2
  19. SpringMVC 文件上传 MultipartFile
  20. 42 Can stress be Avoided ? 压力能够回避吗 ?

热门文章

  1. hosts设置本地虚拟域名
  2. Perl学习三:运算符
  3. PyCharm学习笔记(二) 调试配置
  4. java Date类型的时间显示格式
  5. Python常见文件操作的函数示例
  6. POJ 2955 区间DP Brackets
  7. luogu2219 [HAOI2007]修筑绿化带
  8. Flask+ Angularjs 实例: 创建博客
  9. 【Luogu】P1312Mayan游戏(暴搜)
  10. BZOJ 2242 [SDOI2011]计算器 ——EXGCD/快速幂/BSGS