Guest User

pens.cpp

a guest
May 6th, 2018
434
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. #define int long long
  3. #define FR(i,a,b) for (int i=(a); i<(b); i++)
  4. #define F(i,n) FR(i,0,n)
  5. using namespace std;
  6. typedef long double ld;
  7. const ld PIl = acos((ld)-1);
  8.  
  9. typedef int T;
  10. struct p3 {
  11.     T x,y,z;
  12.     p3 operator+(p3 p) {return {x+p.x, y+p.y, z+p.z};}
  13.     p3 operator-(p3 p) {return {x-p.x, y-p.y, z-p.z};}
  14.     p3 operator*(T d) {return {x*d, y*d, z*d};} // mult. by scalar
  15.     T operator|(p3 p) {return x*p.x + y*p.y + z*p.z;} // dot product
  16.     p3 operator*(p3 p) { // cross product
  17.         return {y*p.z - z*p.y, z*p.x - x*p.z, x*p.y - y*p.x};}
  18. };
  19. T sq(p3 p) {return p|p;} // squared norm
  20. ostream& operator<<(ostream& os, p3 p) {
  21.     return os<<"("<<p.x<<","<<p.y<<","<<p.z<<")";}
  22. istream& operator>>(istream& is, p3 &p) {
  23.     return is>>p.x>>p.y>>p.z;}
  24.  
  25. ld solveBigger(int a, int b, int c, ld disc) {
  26.     assert(disc >= 0);
  27.     if (b > 0)
  28.         return (2*c) / (-b-sqrt(disc));
  29.     else
  30.         return (-b+sqrt(disc)) / (2*a);
  31. }
  32.  
  33. signed main() {
  34.     ios::sync_with_stdio(false);
  35.     cin.tie(NULL);
  36.     vector<p3> p(2), v(2), w(2);
  37.     F(j,2)
  38.         cin >> p[j] >> v[j] >> w[j];
  39.     p3 d = p[1]-p[0];
  40.     int a = v[0]*v[1]|d, b = (v[0]*w[1] + w[0]*v[1])|d, c = w[0]*w[1]|d;
  41.     if (a < 0) a = -a, b = -b, c = -c;
  42.     int disc = b*b - 4*a*c;
  43.     if (disc < 0) cout<<"never\n";
  44.     else {
  45.         ld cot = solveBigger(a, b, c, disc);
  46.         cout << fixed << setprecision(12);
  47.         cout << PIl / 2 - atan(cot) << "\n";
  48.     }
  49. }
RAW Paste Data