题目链接:
ACdream 1006
题意:
题解:纯数学推导。
因为:
所以,
相加一下,
所以,
到这里,就分情况讨论一下,如果
否则就是:
AC代码:
/*
* this code is made by LzyRapx
* Problem: 1006
* Verdict: Accepted
* Submission Date: 2017-06-23 15:52:35
* Time: 28MS
* Memory: 1844KB
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
double A,B;
cin>>A>>B;
if(A>B)
{
printf("%.5lf\n",A - 1 + log2( pow(2.0,B - A) + 1 ));
}
else
{
printf("%.5lf\n",B - 1 + log2( pow(2.0,A - B) + 1 ));
}
}
return 0;
}