-
Notifications
You must be signed in to change notification settings - Fork 0
/
2013_14_C5_5
96 lines (75 loc) · 1.51 KB
/
2013_14_C5_5
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <map>
#include <cmath>
#include <math.h>
#define MOD 1000000007
#define f first
#define s second
#define Z 300005
using namespace std;
typedef pair<int,int> pii;
map< pii , int> mm;
int gcd (int a, int b){
if(b<a) swap(a,b);
if(a == 0 ) return b;
return gcd(b%a,a);
}
long long rec[Z];
long long div6(long long a){
long long pt,ans = 1ll;
int f2,f3,i;
f2 = 0; f3 = 0;
for(i = 0; i <3 ; i++){
pt = a-i;
if(f2==0 && pt%2==0){
pt = pt/2;
f2 =1;
}
if(f3==0 && pt%3==0){
pt = pt/3;
f3 = 1;
}
ans = (ans*pt)%MOD;
}
return ans;
}
int main()
{
long long cnt,i,a,b,c,d;
mm.clear();
pii x;
long long N;
cin >> N;
cnt = 1;
for(i = 0; i < N ; i++){
cin>>a>>b>>c;
if(a<0){
a = -a;
b = -b;
}
d = gcd(abs(a),abs(b));
a = a/d; b = b/d;
x.f = a;
x.s = b;
if(mm.find(x)==mm.end()){
mm[x] = cnt;
rec[cnt] = 0ll;;
cnt++;
}
rec[mm[x]]++;
}
long long ans,now;
ans = (N*(N-1)*(N-2))/(6ll);
for(i = 1; i <cnt; i++){
now = (rec[i]*(rec[i]-1)*(N-rec[i]))/(2ll);
ans -=now;
now = (rec[i]*(rec[i]-1)*(rec[i]-2))/(6ll);
ans -=now;
}
ans = ans%MOD;
cout<<ans<<endl;
return 0;
}