1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| #include<iostream> #include<string> #include<vector> #include<algorithm> #include<map> #include<cmath> #include<iomanip> #define ll long long #define ld long double
using namespace std;
const ll tests[][4] = { {5,1,-5,3}, {99,17,-97,25} };
int main() { std::ios::sync_with_stdio(false); cin.tie(NULL), cout.tie(NULL);
ll a, b, x, y; const ld pi = acos(-1); const ld pi2 = pi / 2; const ld g = 9.8;
ld v0, ax, ay, vx, vy, tan0, sin0, cos0, h0, l0, tt, t0;
ll T; cin >> T; while (T--) { cin >> a >> b >> x >> y; tan0 = (ld)b / a; h0 = y - (-x)*tan0; v0 = sqrt(2 * g*h0); sin0 = sqrt(1 - 1 / (tan0*tan0 + 1)); cos0 = sqrt(1 / (tan0*tan0 + 1)); l0 = (-x) / cos0;//总长度 vx = v0 * sin0; vy = v0 * cos0; ax = g * sin0; ay = g * cos0; t0 = 2 * vy / ay;//单次跳跃时间 //解方程,1/2*ax*t*t+vx*t=l0 tt = (sqrt(vx*vx + 2 * ax*l0) - vx) / ax; cout << (ll)(tt / t0) + 1 << endl; } return 0; }
|