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


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

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

    int res;
    while(true){
        std::cin >> e;
        if(e == 0) break;

        res = INT_MAX;
        for(x=0; x<=e; ++x){
            y_max = pow(e - x, 0.5);
            for(y=0; y<=y_max; ++y){
                z_max = pow(e - x - y*y, 0.34);
                for(z=0; z<=z_max; ++z){
                    if((x+y*y+z*z*z) == e){
                        res = std::min(res, x+y+z);
                    }
                }
            }
        }
        std::cout << res << std::endl;
    }
}