fork download
  1.  
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. #define MOD 100-1 //NA
  5. #define ll long long int
  6. #define rep(i,a,b) for(int i=a;i<=(int)(b);i++)
  7.  
  8. ll n,rt,ans;
  9. ll arr[2005][2005],x[2005],y[2005];
  10. ll sqr[50000000+10];
  11. int main()
  12. {
  13. freopen("##inp.cpp","r",stdin);
  14. //freopen("##out.cpp","w",stdout);
  15. //ios_base::sync_with_stdio(0);
  16. cin>>n;
  17. rep(i,0,n-1) cin>>x[i]>>y[i];
  18. if(n<3) {cout<<"0"; return 0;}
  19. rep(i,0,n-1)
  20. {
  21. rep(j,i+1,n-1)
  22. {
  23. int a=x[j]-x[i],b=y[j]-y[i];
  24. int cur=__gcd(a,b);
  25. if(cur==0) {continue; rt++;}
  26. a=a/cur; b=b/cur;
  27. arr[a+500][b+500]++;
  28. }
  29. }
  30. rep(i,0,3000) sqr[i*i]=i;
  31.  
  32. ans=(n*(n-1)*(n-2))/6ll;
  33. //cout<<ans<<endl;
  34. rep(i,1,1000)rep(j,1,1000)
  35. {
  36. ll cur=1+8ll*arr[i][j];
  37. if(arr[i][j]==0) continue;
  38. cur=(sqr[cur]+1)/2ll;
  39. ans=ans-(cur*(cur-1)*(cur-2))/6ll;
  40. //cc2(cur,ans);
  41. }
  42. ll cur=1+8ll*rt;
  43. cur=(sqrt(cur)+1)/2ll;
  44. ans=ans-(cur*(cur-1)*(cur-2))/6ll;
  45.  
  46. cout<<ans<<endl;
  47. }
  48.  
Success #stdin #stdout 0s 425216KB
stdin
Standard input is empty
stdout
Standard output is empty