-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP102.cpp
More file actions
75 lines (68 loc) · 1.27 KB
/
Copy pathP102.cpp
File metadata and controls
75 lines (68 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
* 用叉积判断点是否在三角形内部。
*/
//Warning: 请自行将txt中的逗号替换成空格!!!
#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define Vector Point
typedef long long LL;
const int MAXN = 1e6 + 5;
const LL limit = 1e16 + 3;
const LL MOD = 1ll<<52+1;
class Point{
private:
int x,y;
public:
Point(){
x=0,y=0;
}
Point(int _x, int _y){
x=_x,y=_y;
}
Point Input(){
scanf("%d%d",&x,&y);
}
void print(){
printf("(%d,%d)\n",x,y);
}
Point operator- (const Point& b){
return Point(x-b.x,y-b.y);
}
int Cross(Vector b){
return x*b.y-y*b.x;
}
};
Point p[5];
Point O;
int sgn(int x){
if(x<0) return -1;
if(x>0) return 1;
return 0;
}
int check(){
int cnt=0;
for(int i=0;i<3;i++){
int j=(i+1)%3;
Vector a=p[j]-p[i];
Vector b=O-p[i];
int temp=a.Cross(b);
cnt+=sgn(temp);
}
if(cnt==-3||cnt==3) return 1;
return 0;
}
int main(){
freopen("p102_triangles.txt","r",stdin);
// freopen("out.txt","w",stdout);
int t=1000;
int ans=0;
while(t--){
for(int i=0;i<3;i++)
p[i].Input();
if(check()) ans++;
}
printf("%d\n",ans);
return 0;
}