Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include<math.h>
- int gcd(long long int a, long long int b)
- {
- if(b>a)
- return gcd(b,a);
- else if (b!=0)
- return gcd(b,a%b);
- else
- return a;
- }
- int main(void) {
- int test;
- scanf("%d",&test);
- while(test--)
- {
- int a,b;
- scanf("%d%d",&a,&b);
- int g = gcd(a,b);
- int i;
- int res=0;
- for(i=1;i<=sqrt(g);i++)
- {
- if(g%i==0)
- {
- if(g/i==i)
- {
- res+=1;
- }
- else
- {
- res+=2;
- }
- }
- }
- printf("%lld\n",res);
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment