Advertisement
Saleh127

spoj comdiv

Mar 2nd, 2021
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int nod(int a)
  5. {
  6. int c=0;
  7. for(int i=1;i*i<=a;i++)
  8. {
  9. if(i*i==a) c+=1;
  10. else if(a%i==0) c+=2;
  11. }
  12. return c;
  13. }
  14.  
  15. int main()
  16. {
  17.  
  18.  
  19. int t;
  20. scanf("%d",&t);
  21. while(t--)
  22. {
  23. int a,b,c;
  24. scanf("%d %d",&a,&b);
  25. c=__gcd(a,b);
  26.  
  27. printf("%d\n",nod(c));
  28. }
  29.  
  30.  
  31. return 0;
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement