Advertisement
Guest User

Untitled

a guest
Sep 20th, 2014
875
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <cstdio>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. const double eps = 1e-6;
  6.  
  7. int t;
  8. int X1, Y1, X2, Y2, X3, Y3, X4, Y4, p;
  9.  
  10. int Cross(int ax, int ay, int bx, int by) { return ax * by - ay * bx; }
  11.  
  12. int main()
  13. {
  14.     scanf("%d", &t);
  15.     for (int tc = 1; tc <= t; tc++) {
  16.         scanf("%d %d %d %d %d %d %d %d %d", &X1, &Y1, &X2, &Y2, &X3, &Y3, &X4, &Y4, &p);
  17.         int ax = X2 - X1, ay = Y2 - Y1;
  18.         int bx = X3 - X1, by = Y3 - Y1;
  19.         int cx = X4 - X1, cy = Y4 - Y1;
  20.         double res = abs((Cross(bx, by, ax, ay) + Cross(cx, cy, bx, by)) / 2.0l);
  21.         printf("Case #%d: %.2lf\n", tc, double(p) / res + eps);
  22.     }
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement