编程介的小学生 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条)

报告相同问题?

悬赏问题

  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)