Space Coconut Grab (AOJ 2012) by ynu_b
Contest: 3472    RunID: 2316084    Status: Time Limit Exceeded    Date: Sun May 14 15:39:16 JST 2017


#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>

int e = 0;
int main(void){
    int x, y, z;

    while(true){
        std::cin >> e;
        if(e == 0) break;
    int z_max = pow(e, 0.34);
    int y_max = pow(e, 0.5);
    int res = INT_MAX;
    for(z = 0; z <= z_max; ++z){
        for(y = 0; y <= y_max; ++y){
            for(x=0; x <= e; ++x){
                if((x + y*y + z*z*z) == e){
                    res = std::min(res, x+y+z);

                }
            }
        }
    }
    std::cout << res << std::endl;
    }
}