#include <cmath>
class Solution {
public:
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     * 
     * @param n int整型 
     * @return int整型
     */
    int cuberoot(int n) {
        int l=0,r=sqrt(n),k;
        while (l<=r) {
            k=(l+r)/2;
            if(n/(k*k)>k)
            {
                l=k+1;
            }
            else if (n/(k*k)<k) {
                r=k-1;
            }
            else if (n/(k*k)==k) {
                return k;
            }
        }
        return r;
    }
};