import std; void main () { int T = readln.chomp.to!int; foreach (_; 0..T) { double p; int K; readln.read(p, K); auto ans = solve(p, K); writeln(format("%.10f", ans)); } } auto solve (double p, int K) { double res = 0; // i 回目まですべてレアキャラ以外を出す確率 : (1-p)^i double not = 1; double P = p; for (int i = 1; i <= K; i++) { if (i == K) { res += i*not; continue; } res += i*not*p; not *= 1-p; } return res; } void read(T...)(string S, ref T args) { auto buf = S.split; foreach (i, ref arg; args) { arg = buf[i].to!(typeof(arg)); } }