Guest User

Untitled

a guest
Feb 17th, 2019
71
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. #include<math.h>
  3. int gcd(long long int a, long long int b)
  4. {
  5. if(b>a)
  6. return gcd(b,a);
  7. else if (b!=0)
  8. return gcd(b,a%b);
  9. else
  10. return a;
  11. }
  12. int main(void) {
  13. int test;
  14. scanf("%d",&test);
  15. while(test--)
  16. {
  17. int a,b;
  18. scanf("%d%d",&a,&b);
  19. int g = gcd(a,b);
  20. int i;
  21. int res=0;
  22. for(i=1;i<=sqrt(g);i++)
  23. {
  24. if(g%i==0)
  25. {
  26. if(g/i==i)
  27. {
  28. res+=1;
  29. }
  30. else
  31. {
  32. res+=2;
  33. }
  34. }
  35. }
  36. printf("%lld\n",res);
  37. }
  38. return 0;
  39. }
Add Comment
Please, Sign In to add comment