Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <vector>
- #include <queue>
- #include <algorithm>
- #include <string>
- #include <stack>
- #include <set>
- #include <map>
- #include <math.h>
- #define pii pair <int,int>
- using namespace std;
- using ll = long long;
- using ld = long double;
- using db = double;
- void cv(vector <int> &v){
- for (auto x: v) cout<<x<<' ';
- cout<<"\n";
- }
- void cvl(vector <ll> &v){
- for (auto x: v) cout<<x<<' ';
- cout<<"\n";
- }
- void cvv(vector <vector <int> > &v){
- for (auto x: v) cv(x);
- cout<<"\n";
- }
- struct ipn{
- int x,y;
- };
- struct rpn{
- db x,y;
- };
- rpn rVec(rpn A, rpn B){
- rpn ab;
- ab.x = A.x - B.x;
- ab.y = A.y - B.y;
- return ab;
- }
- rpn div(rpn A, rpn B, db p, db q){
- rpn res;
- res.x = (q * A.x + p * B.x) / (p + q);
- res.y = (q * A.y + p * B.y) / (p+q);
- return res;
- }
- db dot(rpn a, rpn b){
- return a.x * b.x + a.y * b.y;
- }
- db lgth(rpn a){
- return sqrt(a.x * a.x + a.y * a.y);
- }
- db angl(rpn a, rpn b){
- db an = acos(dot(a, b) / ( lgth(a) * lgth(b)) );
- return an;
- }
- db rCross(rpn a, rpn b){
- return a.y * b.x - a.x * b.y;
- }
- int anglTp(rpn A, rpn B, rpn C){ //возвращает тип угла между AB и AC то есть угла BAC
- rpn ab = rVec(A, B);
- rpn ac = rVec(A, C);
- if (dot(ab, ac) > 0){
- return 1; //острый
- }
- if (dot(ab, ac) == 0){
- return 1;//прямой
- }
- return 2; // тупой
- }
- db rArea(rpn A, rpn B, rpn C){
- rpn ab = rVec(A, B);
- rpn ac = rVec(A, C);
- return fabs( rCross(ab, ac) ); // 2.0
- }
- db hgt(rpn A, rpn B, rpn C){ //height
- db h;
- //cout<<"rArea(B, A, C) = "<<rArea(B, A, C) <<"\n";
- //cout<<"AB = "<<lgth(rVec(A, B))<<"\n";
- h = rArea(B, A, C) / lgth( rVec(A, B) );
- //cout<<"h = "<<h<<"\n";
- if ( anglTp(A, B, C) == 2){
- //cout<<"one\n";
- return lgth( rVec(C, A) );
- }
- if (anglTp (B, A, C) == 2){
- //cout<<"two\n";
- return lgth( rVec(C, B) );
- }
- return h;
- }
- void mk(rpn &x){
- cin>>x.x>>x.y;
- }
- int main()
- {
- ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- cout.precision(20);
- rpn A, B, ans;
- mk(ans);
- mk(A);
- mk(B);
- cout<<fixed<<hgt(A, B, ans);
- }
- /*
- 0 0 6 0 3 30
- 0 100 0 0 50 1000
- 1001.24921972503932465770
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement