Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- long double area(long double x1, long double y1, long double x2, long double y2, long double x3, long double y3)
- {
- long double res;
- res = x1*(y2-y3) + x2*(y3-y1) + x3*(y1-y2);
- res = fabs(res);
- res = res*0.5;
- return res;
- }
- int main()
- {
- int t;
- long double x1,y1,x2,y2,x3,y3,x4,y4,cost;
- cin >> t;
- for ( int l = 1; l <= t; l++ ) {
- cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4 >> cost;
- long double ans = area(x1,y1,x2,y2,x3,y3) + area(x1,y1,x3,y3,x4,y4);
- ans = cost/ans;
- cout << "Case #" << l << ": " << setprecision(2) << fixed << ans << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment