chang2394

Untitled

Oct 18th, 2014
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. long double area(long double x1, long double y1, long double x2, long double y2, long double x3, long double y3)
  6. {
  7.     long double res;
  8.     res = x1*(y2-y3) + x2*(y3-y1) + x3*(y1-y2);
  9.     res = fabs(res);
  10.     res = res*0.5;
  11.     return res;
  12. }
  13. int main()
  14. {
  15.     int t;
  16.     long double x1,y1,x2,y2,x3,y3,x4,y4,cost;
  17.     cin >> t;
  18.     for ( int l = 1; l <= t; l++ ) {
  19.         cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4 >> cost;
  20.         long double ans = area(x1,y1,x2,y2,x3,y3) + area(x1,y1,x3,y3,x4,y4);
  21.         ans = cost/ans;
  22.         cout << "Case #" << l << ": " << setprecision(2) << fixed << ans << endl;
  23.     }
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment