fork(1) download
  1. #include <iostream>
  2. #include <cmath>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. int n[5] = {0};
  8. const int N = 150;
  9.  
  10. void Pow(long long int *P){
  11. for(int i = 0; i < N; ++i){
  12. long long int i2 = i * i;
  13. P[i] = i2 * i2 * i;
  14. }
  15. }
  16.  
  17. void logprint(int en, int* n, long long int *P) {
  18. cout << en << "\t: ";
  19. for (int i = 0; i < 5; ++i) cout << n[i] <<" ";
  20. cout << " : " << P[N] << endl;
  21. }
  22.  
  23. int * Eu(int be, int en, long long int *P, int *n, int j){
  24. //logprint(j, n, P);
  25. for (int i = be; i <= en; ++i){
  26. if (n[4] != 0) return n;
  27. P[N] += P[i]; n[j] = i;
  28. if (j < 3)
  29. n = Eu(i, en, P, n, j + 1);
  30. else {
  31. size_t k = lround(pow(P[N] + 1, 0.2));
  32. if (P[k] == P[N] && k < N) n[4] = k;
  33. }
  34. P[N] -= P[i];
  35. }
  36. return n;
  37. }
  38.  
  39. int * Eu(long long int *P, int en) {
  40. n[4] = 0; P[N] = 0;
  41. return Eu(1, en, P, n, 0);
  42. }
  43.  
  44. int main(){
  45. long long int P[N+1];
  46. Pow(P);
  47. int en;
  48. cin >> en;
  49.  
  50. Eu(P, en);
  51.  
  52. for (int i = 0; i < 5; i++)
  53. cout << n[i] << " ";
  54. return 0;
  55. }
Success #stdin #stdout 1.65s 3468KB
stdin
140
stdout
27 84 110 133 144