#include #include using namespace atcoder; using namespace std; using ll=long long; using ld=long double; ld pie=3.141592653589793; ll mod=1000000007; ll inf=10090000000000000; int main(){ ll t; cin >> t; for (ll o = 0; o < t; o++) { ld p; cin >> p; ll k; cin >> k; vectorx(k+1,0); x[1]=p; ld now=p; for (ll i = 2; i < k; i++) { x[i]=p*(1.0-now); now+=x[i]; } ld ans=0; for (ll i = 1; i < k; i++) { ans+=(ld)i*x[i]; } ans+=k*(1.0-now); cout << setprecision(100) << ans << endl; } }