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


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

int e = 0;

int solve(){
    int x,y,z;

    int res = INT_MAX;
    for(z=0; z<=e; ++z){
        for(y=0;y<=e;++y){
            x = e - y*y - z*z*z;
            if(x >= 0){
                res = std::min(res, x+y+z);
            }
        }
    }
    return res;
}

int main(void){
    while(true){
        std::cin >> e;
        if(e == 0) break;
        std::cout << solve() << std::endl;
    }
}