#include <bits/stdc++.h>
using namespace std;
void solve()
{
double a, d, c, p, n;
cin >> a >> d >> c >> p >> n;
//ct^2 + (2d + c)t - 2(n-a) = 0
double D = (2.0*d + c) * (2.0*d + c) + 8.0 * (n-a) * c;
double T = sqrt(D) - (2.0*d + c);
T /= (2.0*c);
cout << max(0, (int)(ceil(T) * p)) << endl;
}
int main()
{
int t;
cin >> t;
while (t--)
solve();
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgp2b2lkIHNvbHZlKCkKewoJZG91YmxlIGEsIGQsIGMsIHAsIG47CgljaW4gPj4gYSA+PiBkID4+IGMgPj4gcCA+PiBuOwoJLy9jdF4yICsgKDJkICsgYyl0IC0gMihuLWEpID0gMAoJZG91YmxlIEQgPSAoMi4wKmQgKyBjKSAqICgyLjAqZCArIGMpICsgOC4wICogKG4tYSkgKiBjOwoJZG91YmxlIFQgPSBzcXJ0KEQpIC0gKDIuMCpkICsgYyk7CglUIC89ICgyLjAqYyk7Cgljb3V0IDw8IG1heCgwLCAoaW50KShjZWlsKFQpICogcCkpIDw8IGVuZGw7Cn0KCmludCBtYWluKCkKewoJaW50IHQ7CgljaW4gPj4gdDsKCXdoaWxlICh0LS0pCgkJc29sdmUoKTsKCXJldHVybiAwOwp9Cg==