#include #include #include using namespace std; using ll = long long; #include using mint = atcoder::modint998244353; // using mint = long double; #include #include void solve(){ ll n,k; cin>>n>>k; vector a(n); for(int i = 0;i>a[i]; ll sum = 0; for(int i = 0;i use(n),res(n); for(int i = 0;i idx(n); for(int i = 0;i res[j]; return a[i] > a[j]; }); ll now = 0; for(int i = 0;i; priority_queue que; vector f(k+4,0); for(int i = 1;i<=k+3;i++) f[i] = f[i-1] + log(i); auto add = [&](int i) { long double nxt = (use[i]+1) * log(a[i]) - (use[i]+1) * log(sum) - f[use[i]+1]; long double now = use[i] * log(a[i]) - use[i] * log(sum) - f[use[i]]; que.push(make_pair(nxt - now,i)); }; for(int i = 0;i fac(k+1,0); fac[0] = 1; for(int i = 1;i<=k;i++) fac[i] = fac[i-1] * i; ans = fac[k]; for(int i = 0;i>t; while(t--){ solve(); } }