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("%d ",i);c++;}
  19. x=small/i;
  20. if( (x*x)!=small && b%x==0)
  21. {printf("%d\n",x);
  22. c++;}
  23. }
  24. //if(b%a==0)
  25. //c++;
  26. printf("%d\n",c);
  27. }
  28. return 0;
  29. }
  30.  
  31.  
Success #stdin #stdout 0.01s 2728KB
stdin
1
747794 238336
stdout
1 238336
2 119168
59584
34048
29792
17024
14896
12544
8512
7448
6272
4864
4256
3724
3136
2432
2128
1862
1792
1568
1216
1064
931
896
784
608
532
29