Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (n == 3)
- {
- cin >> A.x >> A.y >> B.x >> B.y >> C.x >> C.y;
- line LOL = toline(A, B);
- if (point_in_line(LOL, C) == 0)
- {
- double ans = rast(A, B);
- ans = max(ans, max(rast(A,C),rast(B,C)));
- printf("%.7lf\n", ans);
- cout << 0 << ' ' << 0 << endl << 0 << endl << 2 << endl;
- if(ans==rast(A,B))
- {
- cout<<"1 3"<<endl;
- cout<<"2 3"<<endl;
- }
- if(ans==rast(A,C))
- {
- cout<<"1 2"<<endl;
- cout<<"2 3"<<endl;
- }
- if(ans==rast(B,C))
- {
- cout<<"1 2"<<endl;
- cout<<"1 3"<<endl;
- }
- return 0;
- }
- double sta=rast(B,C),stb=rast(A,C),stc=rast(A,B);
- if((sqr(sta)-sqr(stb)-sqr(stc))/(-2*stb*stc)<-0.5)
- {
- double ans=rast(A,B)+rast(A,C);
- printf("%.7lf\n", ans);
- cout << 0 << ' ' << 0 << endl << 0 << endl << 2 << endl;
- cout<<"1 2"<<endl;
- cout<<"1 3"<<endl;
- return 0;
- }
- if((sqr(stb)-sqr(sta)-sqr(stc))/(-2*sta*stc)<-0.5)
- {
- double ans=rast(A,B)+rast(B,C);
- printf("%.7lf\n", ans);
- cout << 0 << ' ' << 0 << endl << 0 << endl << 2 << endl;
- cout<<"1 2"<<endl;
- cout<<"2 3"<<endl;
- return 0;
- }
- if((sqr(stc)-sqr(stb)-sqr(sta))/(-2*sta*stb)<-0.5)
- {
- double ans=rast(A,C)+rast(B,C);
- printf("%.7lf\n", ans);
- cout << 0 << ' ' << 0 << endl << 0 << endl << 2 << endl;
- cout<<"2 3"<<endl;
- cout<<"1 3"<<endl;
- return 0;
- }
- tvector v1, v2, v3;//dlya AB
- tvector vv3;//dlya AC
- point SR, P1, P2;//dlya otrezka AB
- point RS, PP1, PP2;//dlya otrezka AC
- point F1, F2;
- v1 = create_vector(A,B);
- v2 = create_vector(A,C);
- SR.x = (A.x+B.x)/2;
- SR.y = (A.y+B.y)/2;
- RS.x = (A.x+C.x)/2;
- RS.y = (A.y+C.y)/2;
- double visota = sqrt(3) / 2.0;
- v3.x = v1.y * visota;
- v3.y = -v1.x * visota;
- vv3.x = v2.y * visota;
- vv3.y = -v2.x * visota;
- P1.x = SR.x + v3.x;
- P1.y = SR.y + v3.y;
- PP1.x = RS.x + vv3.x;
- PP1.y = RS.y + vv3.y;
- P2.x = SR.x - v3.x;
- P2.y = SR.y - v3.y;
- PP2.x = RS.x - vv3.x;
- PP2.y = RS.y - vv3.y;
- if (rast(P1, C) > rast(P2, C))
- F1 = P1;
- else
- F1 = P2;
- if (rast(PP1, B) > rast(PP2, B))
- F2 = PP1;
- else
- F2 = PP2;
- line line1 = toline(C, F1), line2 = toline(B, F2);
- point ans = cross_line(line1, line2);
- double answi = rast(ans, A)+rast(ans, B)+rast(ans, C);
- printf("%.7lf\n", answi);
- printf("%.7lf %.7lf\n",ans.x,ans.y);
- printf("3 1 2 3\n0");
- return 0;
- }
Add Comment
Please, Sign In to add comment