Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication1.cpp: определяет точку входа для консольного приложения.
- //
- #include <iostream>
- #include <cstdlib>
- #include <cmath>
- #include <iomanip>
- #include <fstream>
- #include <cstdio>
- using namespace std;
- typedef long double ld;
- typedef long long ll;
- struct tt {
- ld x, y, z, vx, vy, vz;
- };
- tt a[100010];
- ll n;
- ld eps = 1e-8;
- ld mn(ld a, ld b)
- {
- if (a - b > eps)
- return b;
- else
- return a;
- }
- ld mx(ld a, ld b)
- {
- if (b - a > eps)
- return b;
- else
- return a;
- }
- ld f(ld t)
- {
- ld mnx = 1e12, mxx = -1e12, mny = 1e12, mxy = -1e12, mnz = 1e12, mxz = -1e12;
- for (int i = 0; i < n; i++)
- {
- ld x = a[i].x + a[i].vx * t, y = a[i].y + a[i].vy * t, z = a[i].z + a[i].vz * t;
- mnx = mn(x, mnx);
- mny = mn(y, mny);
- mnz = mn(z, mnz);
- mxx = mx(x, mxx);
- mxy = mx(y, mxy);
- mxz = mx(z, mxz);
- }
- return mx(mxx - mnx, mx(mxy - mny, mxz - mnz));
- }
- int main()
- {
- ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- cin >> n;
- for (int i = 0; i < n; i++)
- cin >> a[i].x >> a[i].y >> a[i].z >> a[i].vx >> a[i].vy >> a[i].vz;
- cout << setprecision(4) << fixed;
- ld l = 0, r = 1e10;
- while (r > l + eps)
- {
- double m = (r + l) / 2;
- if (f(m) > f(m + eps))
- l = m;
- else
- r = m;
- }
- cout << f(l) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement