Guest User

Untitled

a guest
Feb 17th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #include<stdio.h>
  2. int gcd(int a, int b)
  3. {
  4. if (b == 0)
  5. return a;
  6. return gcd(b, a % b);
  7.  
  8. }
  9. int main()
  10.  
  11. {
  12.  
  13. int t;
  14.  
  15. scanf("%d",&t);
  16.  
  17. while(t--)
  18.  
  19. {
  20.  
  21. int a,b,c=0,i,h;
  22.  
  23. scanf("%d%d",&a,&b);
  24.  
  25. h= gcd(a,b);
  26.  
  27. for(i=1;i*i<=h;i++)
  28.  
  29. {
  30.  
  31. if(h%i==0)
  32.  
  33. c=c+2;
  34.  
  35.  
  36.  
  37. }
  38.  
  39. i=i-1;
  40.  
  41. if(i*i==h)
  42.  
  43. c--;
  44.  
  45. printf("%d\n",c);
  46.  
  47.  
  48.  
  49. }
  50.  
  51. return 0;
  52.  
  53. }
Add Comment
Please, Sign In to add comment