Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //SkyHawk, CMC MSU
- #include <stdio.h>
- #include <iostream>
- #include <list>
- #include <string>
- #include <vector>
- #include <iterator>
- #include <algorithm>
- #include <cmath>
- #include <cstring>
- #include <set>
- #include <list>
- #include <queue>
- using namespace std;
- #define FOR(i,n) for(int i = 0;i < n;++i)
- #define PII pair<int,int>
- //======================================================================
- //Checking, is point (0,0) in the triangle
- /*
- * Options:
- * IN_TRIANGLE_LOG - writing log
- */
- inline int inTriangle(long long x1,long long y1,long long x2,long long y2,
- long long x3,long long y3)
- {
- #ifdef IN_TRIANGLE_LOG
- cerr << "inTriangle(): " << x1 << " " << y1 << " " << x2 << " " <<
- y2 << " " << x3 << " " << y3;
- #endif
- long long d1 = x1*y2 - y1*x2;
- long long d2 = x2*y3 - y2*x3;
- long long d3 = x3*y1 - y3*x1;
- if((d1>=0) == (d2>=0) && (d1>=0) == (d3>=0))
- {
- if(d1 && d2 && d3)
- return 2;
- else
- return 1;
- }
- return 0;
- }
- int main(int argc, char** argv)
- {
- freopen("INPUT.TXT","r",stdin);
- freopen("OUTPUT.TXT","w",stdout);
- int x1,x2,x3,y1,y2,y3,x,y;
- cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x >> y;
- x1-=x;
- x2-=x;
- x3-=x;
- y1-=y;
- y2-=y;
- y3-=y;
- cout << (inTriangle(x1,y1,x2,y2,x3,y3)>0?"In":"Out") << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement