fork download
  1. #include<stdio.h>
  2. #include<math.h>
  3. int main()
  4. {
  5. int c;
  6. long int a,b,small,i,n,x;
  7. scanf("%ld",&n);
  8. while(n--)
  9. {
  10. c=0;
  11. scanf("%ld %ld",&a,&b);
  12. small=a;
  13. if(b<a)
  14. small=b;
  15. for(i=1;i<=sqrt(small);i++)
  16. {
  17. if((a%i)==0 && (b%i)==0)
  18. {{printf("%ld ",i);c++;}
  19. x=small/i;
  20. if( (x*x)!=small && b%x==0)
  21. {printf("%ld\n",x);c++;}
  22. }
  23. //if(b%a==0)
  24. //c++;
  25. }
  26. printf("%d\n",c);
  27.  
  28. }
  29. system("pause");
  30. return 0;
  31. }
Success #stdin #stdout 0.02s 5312KB
stdin
1
747794 238336
stdout
1 238336
2 119168
4