Advertisement
Guest User

Untitled

a guest
Jan 27th, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <set>
  3. #include <cmath>
  4. using namespace std;
  5.  
  6. int NOD(int a, int b)
  7. {
  8. int mod=1;
  9. a=abs(a);b=abs(b);
  10. if(a==b){return a;}
  11. if(b>a)
  12. {
  13. mod=a;a=b;b=mod;
  14. }
  15. if(b==0)
  16. {
  17. return a;
  18. }
  19. while(mod)
  20. {
  21. mod=a%b;
  22. if(mod)
  23. {
  24. a=b;
  25. b=mod;
  26. }
  27. }
  28. return b;
  29. }
  30.  
  31.  
  32. int main()
  33. {
  34. set<pair<int,int>>drobes;
  35. int n;
  36. cin>>n;
  37. for(int i = 0; i < n; i++)
  38. {
  39. int a, b;
  40. cin>>a>>b;
  41. int q = NOD(a,b);
  42. a/=q;b/=q;
  43. drobes.insert(make_pair(a,b));
  44. }
  45. cout<<drobes.size();
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement