fork download
  1. #include <stdint.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5. int main(void)
  6. {
  7. uintmax_t n, m;
  8. if (scanf("%ju", &n) != 1 || scanf("%ju", &m) != 1)
  9. exit(EXIT_FAILURE);
  10.  
  11. for (uintmax_t product = n*m; product; --product)
  12. for (uintmax_t i = n; i; --i)
  13. if (product % i == 0 && product / i <= m)
  14. printf("%ju %ju\n", i, product / i);
  15. }
  16.  
Success #stdin #stdout 0s 4340KB
stdin
5 6
stdout
5 6
5 5
4 6
5 4
4 5
3 6
4 4
5 3
3 5
4 3
3 4
2 6
5 2
2 5
3 3
4 2
2 4
3 2
2 3
1 6
5 1
1 5
4 1
2 2
1 4
3 1
1 3
2 1
1 2
1 1