Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define x first
- #define y second
- #define pdd pair<double, double>
- double sqr(double a) {
- return a*a;
- }
- double dist(auto a, auto b) {
- double ret = sqr(a.x-b.x) + sqr(a.y-b.y);
- return sqrt(ret);
- }
- pdd third_point(auto a, auto b, auto p) {
- pdd c;
- //p(x, y) = (x1+x2+x3)/3, (y1+y2+y3)/3
- c.x = p.x*3.0-(a.x+b.x);
- c.y = p.y*3.0-(a.y+b.y);
- return c;
- }
- double calc(auto a, auto b, auto c) {
- double area = abs((a.x*(b.y-c.y) + b.x*(c.y-a.y) + c.x*(a.y-b.y))/2.0);
- return area*2.0/dist(b, c);
- }
- int main() {
- ios_base::sync_with_stdio(false);
- int T;
- pdd a, b, c, i, j;
- cin>>T;
- while(T--) {
- cin>>a.x>>a.y>>b.x>>b.y>>c.x>>c.y>>i.x>>i.y>>j.x>>j.y;
- pdd h = third_point(a, c, i);
- pdd f = third_point(b, c, j);
- double height = calc(b, h, f);
- double ac = dist(a, c);
- double bc = dist(b, c);
- double agdc = ac * height;
- double bgec = bc * height;
- cout<<fixed<<setprecision(9)<<abs(agdc - bgec)<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement