Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- #include <stdlib.h>
- long int gcd(long int m,long int n)
- {
- if(n==0)
- {
- return m;
- }
- return gcd(n,m%n);
- }
- int comDiv(long int x,long int y)
- {
- long int g,c=0;
- if(x==y)
- {
- g=x;
- }
- if(x<y)
- {
- g=gcd(y,x);
- }
- else
- {
- g=gcd(x,y);
- }
- for(int i=1;i<=sqrt(g);i++)
- {
- if(g%i==0)
- {
- if(g/i==i)
- {
- c+=1;
- }
- else
- {
- c+=2;
- }
- }
- }
- return c;
- }
- int main()
- {
- long int n,x,y,result;
- scanf("%ld",&n);
- for(int i=0;i<n;i++)
- {
- scanf("%ld%ld",&x,&y);
- result=comDiv(x,y);
- printf("%ld",result);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement