Space Coconut Grab (AOJ 2012) by ynu_b
Contest: 3472    RunID: 2316169    Status: Wrong Answer    Date: Sun May 14 16:37:26 JST 2017


#include <iostream>
#include <cmath>

int e = 0;

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

    int y_max, z_max;
    for(x=0; x<=e; ++x){
        y_max = sqrt(e-x) + 1;
        for(y=0; y<=y_max; ++y){
            z_max = pow(e-x-y*y, 1.0/3.0) + 1;
            for(z=0; z<=z_max; ++z){
                if((x+y*y+z*z*z) == e){
                    return x + y + z;
                }
            }
        }
    }
    return 0;
}

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