Advertisement
Guest User

SPOJ - LINES

a guest
Jan 8th, 2015
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. /*Author: Sudarshan a.k.a sidchelseafan
  2. Institute: Bits Hyd */
  3. #include<iostream>
  4. #include<cstring>
  5. #include<string>
  6. #include<cstdio>
  7. #include<cmath>
  8. #include<vector>
  9. #include<set>
  10. using namespace std;
  11. #define ll long long
  12. #define mp make_pair
  13. #define pb push_back
  14. #define MX -1e9
  15. #define SZ 200
  16. using namespace std;
  17. pair<double,double> arr[SZ+5];
  18. bool cmp(pair<double,double>& l,pair<double,double>& r){
  19. if (l.first!=r.first)
  20. return (l.first < r.first);
  21. else
  22. return (l.second < r.second);
  23. }
  24. int main(){
  25.  
  26. int n;
  27. while(1){
  28. scanf("%d",&n);
  29. if (n==0)
  30. break;
  31. else{
  32. for (int i=0;i<n;i++)
  33. scanf("%lf %lf",&arr[i].first,&arr[i].second);
  34.  
  35. set < double > q;
  36. int f=0;
  37. for (int i=0;i<n-1;i++){
  38. for (int j=i+1;j<n;j++){
  39. if (arr[j].first==arr[i].first)
  40. f=1;
  41. else
  42. q.insert((arr[j].second-arr[i].second)/(arr[j].first-arr[i].first));
  43. }
  44. }
  45. printf("%d\n",(int)q.size()+f);
  46.  
  47. }
  48. }
  49. return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement