#include using namespace std; //make_tuple emplace_back next_permutation push_back make_pair second first setprecision #if MYDEBUG #include "lib/cp_debug.h" #else #define DBG(...) ; #endif using LL = long long; using Matrix = vector>; constexpr LL LINF=334ll<<53; constexpr int INF=15<<26; constexpr LL MOD=1E9+7; struct Problem{ int t; double w,v,gx,gy,p; vector>> mat; vector> coeff; vector> ans; Problem(int t):t(t),mat (t+1,vector>(2,vector(2))),coeff (2*t+2,vector(2*(2*t+2))),ans (2*t+2,vector(1)){}; void multiply(const Matrix &a, const Matrix &b, Matrix &ret){ //ret=a*b int k=a.size(),l=a[0].size(),m=b[0].size(); if(l!=b.size()) DBG("wrong size") for(int h=0;h=0; --j){ for(int i=0; i> p >> w >> v >> gx >> gy; mat[0]={{1,0},{0,1}}; mat[1]={{v+1,-w},{w,v+1}}; for(int i=2; i<=t; ++i){ for(int j=0; j<2; ++j){ for(int k=0; k<2; ++k){ for(int l=0; l<2; ++l){ mat[i][j][k]+=mat[i-1][j][l]*mat[1][l][k]; } } } } //DBG(mat) double dx,dy; dx = gx-mat[t][0][0]; dy = gy-mat[t][1][0]; //DBG(dx,dy) for(int i=0; i<2*t+2; ++i){ coeff[i][i+2*t+2]=1; } vector c1(2*t+1),c2(2*t+1); for(int i=0; i> rhs (2*t+2,vector(1)); for(int i=0; i<2*t; ++i){ coeff[i][i]=2; coeff[i][2*t]=-c1[i]; coeff[i][2*t+1]=-c2[i]; coeff[2*t][i]=-c1[i]; coeff[2*t+1][i]=-c2[i]; } vector> init (2*t+2,vector(2*t+2)),a(init); for(int i=0; i<2*t+2; ++i){ for(int j=0; j<2*t+2; ++j){ init[i][j]=coeff[i][j]; } } rhs[2*t][0]=c1[2*t]; rhs[2*t+1][0]=c2[2*t]; //DBG(coeff) sweepout(coeff); //DBG(coeff) vector> ret (2*t+2,vector(2*t+2)); for(int i=0; i<2*t+2; ++i){ for(int j=0; j<2*t+2; ++j){ ret[i][j]=coeff[i][j+2*t+2]; } } //DBG(ret) //DBG(rhs) multiply(ret,rhs,ans); multiply(init,ret,a); //DBG(a) //DBG(ans) double square =0; for(int i=0; i> n; for(int i=0; i> t; Problem p(t); p.solve(); } return 0; }