fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int root = sqrt(2017.0);
  5. for (int a=2; a<=root; a++) {
  6. for (int b=2; b<=root; b++) {
  7.  
  8. if (pow(a, b)>2017) {
  9. break;
  10. }
  11.  
  12. for (int c=2; c<=root; c++) {
  13. for (int d=2; d<=root; d++) {
  14.  
  15. if (pow(a, b)+c>2017) {
  16. break;
  17. }
  18.  
  19. if (pow(c, d)>2017) {
  20. break;
  21. }
  22.  
  23. if (pow(a, b) + pow(c, d) == 2017) {
  24. printf("%d^%d+%d^%d\n", a, b, c, d);
  25. }
  26. }
  27. }
  28. }
  29. }
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0s 2168KB
stdin
Standard input is empty
stdout
3^4+44^2
9^2+44^2
12^3+17^2
17^2+12^3
44^2+3^4
44^2+9^2