编程介的小学生 2017-08-23 03:15 采纳率: 20.5%
浏览 570
已采纳

To Go or Not to Go

Wyest and Winsty are two lazy kids who'd rather eat some snacks in the dorm than go to the dining hall. Wyest, however, wants to be healthy occasionally, then she'd persuade Winsty to have meals together, with the reason "Vitta will love you more if you grow some muscle". Since Wyest likes it uncertain, she comes up with a way to decide whether they should step out of their dorms at dinner time.

They randomly choose two positive integers x, y and decide whether they're going or not by the low -th bit of x (where l is the length of x in binary representation, and define the lowest bit to be the zeroth). If the bit is an '1', they get up to the dining hall, or they just continue staying in front of their computers. Now Wyest wonders what the probability of their having meals is, if they give a range to x.

Input

The first line of input is the number of test cases T, then T lines follow, each is a test case with two positive integers a and b, both not larger than 50,000,000. a is guaranteed not to be larger than b. x is randomly chosen from the interval [a,b]. No limit on y.

Output

For each case in the input, output a separate line containing the probability (accurate to 6 fractional digits) of getting an '1' in the way described above and clarified below.

Sample Input

1
4 5
Sample Output

0.500000

  • 写回答

2条回答 默认 最新

  • threenewbee 2017-08-27 14:51
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)