Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <set>
- #include <cmath>
- using namespace std;
- int NOD(int a, int b)
- {
- int mod=1;
- a=abs(a);b=abs(b);
- if(a==b){return a;}
- if(b>a)
- {
- mod=a;a=b;b=mod;
- }
- if(b==0)
- {
- return a;
- }
- while(mod)
- {
- mod=a%b;
- if(mod)
- {
- a=b;
- b=mod;
- }
- }
- return b;
- }
- int main()
- {
- set<pair<int,int>>drobes;
- int n;
- cin>>n;
- for(int i = 0; i < n; i++)
- {
- int a, b;
- cin>>a>>b;
- int q = NOD(a,b);
- a/=q;b/=q;
- drobes.insert(make_pair(a,b));
- }
- cout<<drobes.size();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement