#include "testlib.h" #include const int maxK = 10'000'000; int main() { registerValidation(); int T = inf.readInt(1,1000,"T"); if(T!=4 && T!=1000) inf.quit(_wa, ("Integer parameter [name=T] equals to " + vtos(T) + ", violates the restriction \"T=4 OR 1000\"").c_str()); inf.readEoln(); for(int testcase_id=1; testcase_id<=T; testcase_id++){ std::string testcase_id_s = " for testcase " + vtos(testcase_id); double p = inf.readStrictReal(0.0,1.0,1,10,"p"+testcase_id_s); inf.readSpace(); int K = inf.readInt(0,maxK,"K"+testcase_id_s); inf.readEoln(); if(p == 0){ printf("%d\n",K); } else{ double ans = (1.0-pow(1.0-p,K)) / p; printf("%.12f\n",ans); } } inf.readEof(); return 0; }