fork download
  1. #include <bits/stdc++.h>
  2. #define MAX 1000001
  3. #define INF 1000000000000000000
  4. #define M 1000000007
  5. #define ll long long
  6. #define zero(x) memset(x,0,sizeof(x))
  7. using namespace std;
  8.  
  9. map<double,ll> mp;
  10. vector<double> v;
  11. vector<ll> use;
  12. int tot;
  13.  
  14. ll dp[MAX][4];
  15.  
  16. int main(){
  17. int n;
  18. cin >> n;
  19. tot = 0;
  20. for (int i=0;i<n;i++){
  21. double waste,num,den;
  22. cin >> num >> den >> waste;
  23. double sl;
  24. if (!den) sl = INF;
  25. else sl = num/den;
  26. if (!mp[sl]){
  27. v.push_back(sl);
  28. tot++;
  29. }
  30. mp[sl]++;
  31. }
  32. for (int i=0;i<tot;i++) use.push_back(mp[v[i]]);
  33. if (tot<3){
  34. cout << 0;
  35. return 0;
  36. }
  37.  
  38. for(int i=0;i<3;i++) dp[tot][i] = 1;
  39. for(int i=0;i<=tot;i++) dp[i][3] = 1;
  40. for (int i=tot-1;i>=0;i--){
  41. for (int j=2;j>=0;j--){
  42. if (i==(tot-(3-j))) dp[i][j] = use[i]*dp[i+1][j+1];
  43. else dp[i][j] = dp[i+1][j]+dp[i+1][j+1]*use[i];
  44. }
  45. }
  46. cout << dp[0][0];
  47. return 0;
  48. }
Success #stdin #stdout 0s 46488KB
stdin
5
-5 3 0
-5 -3 -30
0 1 0
3 7 35
1 -2 -1
stdout
10