fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int t;
  6. cin >> t;
  7. while (t--) {
  8. int n;
  9. cin >> n;
  10. bool found = false;
  11. for (int x = 1; x <= n; x++) {
  12. for (int y = 1; y <= n; y++) {
  13. if (x * x * y + y * y * x == n) {
  14. cout << x << " " << y << endl;
  15. found = true;
  16. break;
  17. }
  18. }
  19. if (found) break;
  20. }
  21. if (!found) cout << -1 << endl;
  22. }
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0.46s 5316KB
stdin
5
3
7
42
31250
20732790
stdout
-1
-1
1 6
25 25
26 2587207