Problem:


Space Coconut Crab

宇宙ヤシガニ

English text is not available in this practice contest.

ケン・マリンブルーは，宇宙ヤシガニを求めて全銀河を旅するスペースハンターである．宇宙ヤシガニは，宇宙最大とされる甲殻類であり，成長後の体長は 400 メートル以上，足を広げれば 1,000 メートル以上にもなると言われている．既に多数の人々が宇宙ヤシガニを目撃しているが，誰一人として捕らえることに成功していない．

ケンは，長期間の調査によって，宇宙ヤシガニの生態に関する重要な事実を解明した．宇宙ヤシガニは，驚くべきことに，相転移航法と呼ばれる最新のワープ技術と同等のことを行い，通常空間と超空間の間を往来しながら生きていた．さらに，宇宙ヤシガニが超空間から通常空間にワープアウトするまでには長い時間がかかり，またワープアウトしてからしばらくは超空間に移動できないことも突き止めた．

そこで，ケンはついに宇宙ヤシガニの捕獲に乗り出すことにした．戦略は次のとおりである．はじめに，宇宙ヤシガニが通常空間から超空間に突入する際のエネルギーを観測する．このエネルギーを e とするとき，宇宙ヤシガニが超空間からワープアウトする座標 (x, y, z) は以下の条件を満たすことがわかっている．

x, y, z はいずれも非負の整数である．

x + y2 + z3 = e である．

上記の条件の下で x + y + z の値を最小にする．

これらの条件だけでは座標が一意に決まるとは限らないが，x + y + z の最小値を m としたときに，ワープアウトする座標が平面 x + y + z = m 上にあることは確かである．そこで，この平面上に十分な大きさのバリアを張る．すると，宇宙ヤシガニはバリアの張られたところにワープアウトすることになる．バリアの影響を受けた宇宙ヤシガニは身動きがとれなくなる．そこをケンの操作する最新鋭宇宙船であるウェポン・ブレーカー号で捕獲しようという段取りである．

バリアは一度しか張ることができないため，失敗するわけにはいかない．そこでケンは，任務の遂行にあたって計算機の助けを借りることにした．あなたの仕事は，宇宙ヤシガニが超空間に突入する際のエネルギーが与えられたときに，バリアを張るべき平面 x + y + z = m を求めるプログラムを書くことである．用意されたテストケースの全てに対して正しい結果を出力したとき，あなたのプログラムは受け入れられるであろう．

Input

入力は複数のデータセットで構成される．各データセットは 1 行のみからなり，1 つの正の整数 e (e ≦ 1,000,000) が含まれる．これは，宇宙ヤシガニが超空間に突入した際のエネルギーを表す．入力は e = 0 の時に終了し，これはデータセットには含まれない．

Output

各データセットについて，m の値を 1 行に出力しなさい．出力には他の文字を含めてはならない．

Sample Input

1
2
4
27
300
1250
0

Output for the Sample Input

1
2
2
3
18
44



Sample input:
1
2
4
27
300
1250
0


Sample output:
1
2
2
3
18
44

Submission status: Wrong Answer

Solution code:
while 1:
    e = int(input().strip())
    if e ==0:break
    m=e
    z =0
    '''
    while z**3 <= e:
        y=0
        while y **2 <= e - z**3:
            x = e - y**2 - z**3 
            if m > x+y+z: m = x+y+z 
            y+=1
        z+=1
    '''
    print(m)

Submission status: Wrong Answer

Solution code:
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        while True:
            e = input()
            if e == 0:
                break
            m = float('inf')
            for z in range(11):
                for y in range(1001):
                    x = e - z ** 3 - y ** 2
                    if x >= 0:
                        m = min(m, x + y + z)
            print m
        return None

if __name__ == '__main__':
    m = Main()
    m.solve()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

while True:
    m = int(input())
    if m == 0:
        break
    ans = 10**9
    for i in range(int(m**(1/3))+1):
        y = int((m-i**3)**(1/2))
        x = m - y ** 2 - i ** 3
        ans = min(ans,x+y+i)
    print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

while True:
    m = int(input())
    if m == 0:
        break
    ans = 10**9
    for i in range(int(m**(1/3))+1):
        if i**3 > m:
            continue
        y = int((m-i**3)**(1/2))
        x = m - y ** 2 - i ** 3
        ans = min(ans,x+y+i)
    print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

while True:
    m = int(input())
    if m == 0:
        break
    ans = 10**9
    for i in range(int(m**(1/3))+1):
        y = int((m-i**3)**(1/2))
        x = m - y ** 2 - i ** 3
        if y < 0 or x < 0:
            continue
        ans = min(ans,x+y+i)
    print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from math import sqrt

while True:
    m = int(input())
    if m == 0:
        break
    ans = 10**9
    for i in range(int(m**(1/3))+1):
        y = int(sqrt(m-i**3))
        x = m - y ** 2 - i ** 3
        if y < 0 or x < 0:
            continue
        ans = min(ans,x+y+i)
    print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from math import sqrt

while True:
    m = int(input())
    if m == 0:
        break
    ans = 10**9
    for i in range(int(m**(1/3))+1):
        y = int(sqrt(m-i**3))
        x = m - (y ** 2 + i ** 3)
        if y < 0 or x < 0:
            continue
        ans = min(ans,x+y+i)
    print(ans)

Submission status: Wrong Answer

Solution code:
while(1):
    e=int(raw_input())
    if e==0:
        break
    else:
        sum=99999999999999
        zmax=int(e**(1/3.0))
        for z in range(zmax+1):
            edash=e-z**3
            y=int(edash**(1/2.0))
            x=edash-y**2
            if x+y+z<sum:
                sum=x+y+z
        print sum

Submission status: Wrong Answer

Solution code:
cubics = [ x * x * x for x in range(0, 100)]
squares = [ x * x for x in range(0, 1000) if x * x < 100 ** 3 - 99 ** 3]
while True:
    x, y, z = 0, 0, 0
    e = int(input())
    if e == 0: break
    for i in range(len(cubics)):
        if e - cubics[i] < 0:
            e -= cubics[i - 1]
            z = i - 1
            break
    for i in range(len(squares)):
        if e - squares[i] < 0:
            e -= squares[i -1]
            y = i - 1
            break
    x = e
    print(x + y + z)

Submission status: Wrong Answer

Solution code:
import math
targ = int(input())
y,z = 0,0
while True:
    minans = float("inf")
    if (targ ** ( 1 / 3)) == int(targ ** ( 1 / 3)):
        z = int(targ ** ( 1 / 3))
        targ = 0
    elif (targ ** ( 1 / 2)) == int(targ ** ( 1 / 2)):
        y = int(targ ** ( 1 / 2))
        targ = 0
    else:
        for n in range(math.ceil(targ ** ( 1 / 3))):
            if minans == 0:
                break
            m = int(math.sqrt(targ - n**3))
            if (n ** 3) + (m **2) > targ:
                break
            if minans > targ - (n ** 3 + m**2) + n + m:
                minans = targ - (n ** 3 + m**2) + n + m
    if minans != float("inf"):
        print(minans)
    else:
        print(y + z)
    targ = int(input())
    if targ == 0:
        break

Submission status: Wrong Answer

Solution code:
#coding: utf-8
import math

def yis(z):
    y = int(math.floor(math.sqrt(e - z * z * z)))
    return y

while True:
    e = int(raw_input())
    y = 0
    z = 0
    if e == 0:
        break
    for i in range(100):
        if i * i * i > e:
            z = i - 1
            break
    n = z
    m = e
    for i in range(n + 1):
        y = yis(z)
        m = min(m,e - y * y - z * z * z + y + z)
        z = z - 1
    print m

Submission status: Wrong Answer

Solution code:
#coding: utf-8
import math

def yis(z):
    y = int(math.floor(math.sqrt(e - z * z * z)))
    return y

while True:
    e = int(raw_input())
    y = 0
    z = 0
    if e == 0:
        break
    for i in range(101):
        if i * i * i > e:
            z = i - 1
            break
    n = z
    m = e
    for i in range(n + 1):
        y = yis(z)
        m = min(m,e - y * y - z * z * z + y + z)
        z = z - 1
    print m

Submission status: Wrong Answer

Solution code:
import math

# 1. z ????±???????
# 2. y ??? ???y**2 < (e - z**3)???????????????y????????§???
# 3. x ??? e - y**2 - z**3
# ?????????e????????????????????????101???
while True:
    e = int(input())
    if e == 0:
        break

    min_e = e
    for i in range( math.floor(pow(e, 1.0/3.0)) + 1 ):
        z = i
        y = math.floor(math.sqrt(e - i**3))
        x = e - y**2 - z**3
        if ( (x + y + z) < min_e ):
            min_e = x + y + z

    print(min_e)

Submission status: Wrong Answer

Solution code:
while True:
    e = int(input())
    if e == 0:
        break
    ans = float('inf')
    max_z = int(e ** (1 / 3))
    for z in range(max_z, -1, -1):
        y = int((e - z ** 3) ** 0.5)
        if y + z >= ans:
            break
        ans = min(ans, e - y ** 2 - z ** 3 + y + z)
    print(ans)

Submission status: Wrong Answer

Solution code:
while True:
    e = int(input())
    if e == 0:
        break
    ans = float('inf')
    max_z = int(e ** (1 / 3))
    for z in range(max_z, -1, -1):
        y = int((e - z ** 3) ** 0.5)
        ans = min(ans, e - y ** 2 - z ** 3 + y + z)
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys

inf = 1<<30

def solve():
    while 1:
        e = int(sys.stdin.readline().rstrip())

        if e == 0:
            return

        ans = inf

        z0 = int(e**(1/3))

        for z in range(max(0, z0 - 10), z0 + 10):
            if e - z**3 < 0:
                break

            y0 = int((e - z**3)**0.5)
            for y in range(max(0, y0 - 10), y0 + 10):
                x = e - z**3 - y**2

                if x < 0:
                    break

                ans = min(ans, x + y + z)
                
        print(ans)

if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
import sys

inf = 1<<30

def solve():
    while 1:
        e = int(sys.stdin.readline().rstrip())

        if e == 0:
            return

        ans = inf

        for z in range(int(e**(1/3)) + 1):
            rest = e - z**3
            y = int((rest)**0.5)
            x = rest - y**2

            ans = min(ans, x + y + z)

        print(ans)

if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
# your code goes here
#grab
e=int(input())
while e>0:
    z=0
    while z**3<=e:
        z+=1
    z-=1
    f=z**3
    f=e-f
    y=0
 #   print(f)
    while y*y<=f:
        y+=1
    y-=1
    f-=y*y
    f+=y+z
 #   print(f)
    y=0
    while y*y<=e:
        y+=1
    y-=1
    e-=y*y
    z=0
    while z**3<=e:
        z+=1
    z-=1
    z**=3
    e-=z
    e+=y+z
    if e<f:
        f=e
    print(f)
    e=int(input())

Submission status: Wrong Answer

Solution code:
# your code goes here
#grab
e=int(input())
#e=1250
while e>0:
    z=0
    while z**3<=e:
        z+=1
    z-=1
    f=z**3
    f=e-f
    y=0
 #   print(f)
    while y*y<=f:
        y+=1
    y-=1
    f-=y*y
    f+=y+z
   # print(f)
    y=0
    while y*y<=e:
        y+=1
    y-=1
    e-=y*y
    z=0
    while z**3<=e:
        z+=1
    z-=1
    e-=z**3
    e+=y+z
    if e<f:
        f=e
 #   print(y)
  #  print(z)
  #  print(e)
    print(f)
    e=int(input())
#    e=0

Submission status: Wrong Answer

Solution code:
while True:
    e=int(input())
    if e==0:
        break
    m=e
    for z in range(int(e**(1/3)),-1,-1):
        temp=e-z**3
        y=int(temp**(1/2))
        x=temp-y**2
        if x>=0 and (x+y+z<m):
            m=x+y+z
    print(m)

Submission status: Wrong Answer

Solution code:
while(True):
    e = int(input())
    if e==0:
        break
    ans = pow(10,16)
    z_max = int(pow(e,1/3))
    for z in range(z_max+1):
        y = int(pow(e-z**3,1/2))
    
        ans = min(ans,e-y*y+y-z*z*z+z)
    print(ans)

Submission status: Wrong Answer

Solution code:
while(True):
  e = int(input())
  if e == 0:
    quit()
  i = int(e ** (1/3))
  j = (int(e - i ** 3)**0.5)
  print(e - i ** 3 - j ** 2 + i + j)

Submission status: Wrong Answer

Solution code:
while(True):
  e = int(input())
  if e == 0:
    quit()
  i = int(e ** (1/3))
  j = int((e - i ** 3)**0.5)
  print(e - i ** 3 - j ** 2 + i + j)

Submission status: Wrong Answer

Solution code:
while(True):
  e = int(input())
  if e == 0:
    quit()
  ans = e
  for i in range(0,int(e ** (1/3))+1):
      j = int((e - i ** 3)**0.5)
      k = e - i ** 3 - j ** 2 + i + j
      if k < ans:
          ans = k
  print(ans)

Submission status: Wrong Answer

Solution code:
while(True):
  e = int(input())
  if e == 0:
    quit()
  ans = e
  for i in range(0,int(e ** (1/3))+1):
      j = int((e - i ** 3)**0.5)
      k = e - i ** 3 - j ** 2 + i + j
      if k < ans:
          ans = k
  print(ans)
  j, k = 0,0

Submission status: Wrong Answer

Solution code:
from math import floor
while(True):
  e = int(input())
  if e == 0:
    break
  ans = e
  for i in range(0,floor(e ** (1/3))+1):
      j = floor((e - i ** 3)**0.5)
      k = e - i ** 3 - j ** 2 + i + j
      if k < ans:
          ans = k
  print(ans)

Submission status: Wrong Answer

Solution code:
import math


def solve(e):
    k = 2 ** 32
    for z in range(99, -1, -1):
        z3 = z * z * z
        if z3 > e:
            continue
        e2 = e - z3

        ylm = int(math.sqrt(e2))
        xzlm = 3 * z * z + 3 * z + 1

        for y in range(ylm, -1, -1):
            y2 = y * y
            if e2 > (y + 1) * (y + 1):
                break
            e3 = e2 - y2

            xylm = 2 * y + 1
            x = e3
            if x > xylm or x > xzlm:
                continue
            k = min(k, x + y + z)
    return k


def main():
    while True:
        a = int(input())

        if a == 0:
            break

        print(solve(a))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
while 1:
    n=int(input())
    if not n:break
    a=n**(1/2)
    b=n**(1/3)
    if int(a)==a:
        print(int(a))
    elif int(b)==b:
        print(int(b))
    else:
        l=[]
        for z in range(int(b)+1):
            y=int((n-z**3)**(1/2))
            x=n-(y**2+z**3)
            l.extend([sum([x,y,z])])
        print(min(l))

Submission status: Wrong Answer

Solution code:
while 1:
    n=int(input())
    if not n:break
    b=n**(1/3)
    l=[]
    for z in range(int(b)+1):
        y=int((n-z**3)**(1/2))
        x=n-(y**2+z**3)
        l.extend([sum([x,y,z])])
    print(min(l))

Submission status: Wrong Answer

Solution code:
while 1:
  n=int(input())
  if not n:break
  m=n
  for z in range(int(n**(1/3))+1):
    y=int((n-z**3)**(1/2))
    x=n-y**2-z**3
    m=min(m,x+y+z)
  print(m)

Submission status: Wrong Answer

Solution code:
print 1

Submission status: Wrong Answer

Solution code:
import sys
import math

while True:
    e = int(sys.stdin.readline())
    if e == 0:
        break
    result = 1000000
    """for z in xrange(int(math.pow(e, 1.0/3)), -1, -1):
        for y in xrange(int(math.pow(e - math.pow(z, 3), 1.0 / 2)), -1, -1):
            x = e - math.pow(z, 3) - math.pow(y, 2)
            if x < 0:
                continue
            result = min(result, int(x + y + z))"""
    print result

Submission status: Wrong Answer

Solution code:
import sys
import math

while True:
    e = int(sys.stdin.readline())
    if e == 0:
        break
    result = 1000000
    for z in xrange(int(math.pow(e, 1.0/3)), -1, -1):
        for y in xrange(int(math.pow(e - math.pow(z, 3), 1.0 / 2)), -1, -1):
            pass
            """x = e - math.pow(z, 3) - math.pow(y, 2)
            if x < 0:
                continue
            result = min(result, int(x + y + z))"""
    print result

Submission status: Wrong Answer

Solution code:
import sys
import math

while True:
    e = int(sys.stdin.readline())
    if e == 0:
        break
    result = 1000000
    for z in xrange(int(math.pow(e, 1.0/3)), -1, -1):
        for y in xrange(int(math.pow(e - math.pow(z, 3), 1.0 / 2)), -1, -1):
            pass
            #x = e - math.pow(z, 3) - math.pow(y, 2)
            #if x < 0:
            #    continue
            #result = min(result, int(x + y + z))
    print result

Submission status: Wrong Answer

Solution code:
def solve(e):
    m = 1<<30
    for z in range(int(e**(1.0/3))+1):
        y = int((e-z*z*z)**(1.0/2))
        x = e - z*z*z - y*y
        m = min(m, x+y+z)
    return m

while 1:
    e = input()
    if e==0 : break
    print solve(e)

Submission status: Wrong Answer

Solution code:
def solve(e):
    m = 1<<30
    for z in range(int(e**(1.0/3))+1):
        y = int((e-z*z*z)**(1.0/2) + 1e-7)
        x = e - z*z*z - y*y
        m = min(m, x+y+z)
    return m

while 1:
    e = input()
    if e==0 : break
    print solve(e)

Submission status: Wrong Answer

Solution code:
def solve(e):
    m = 1<<100
    for z in range(int(e**(1.0/3.0))+1):
        y = int((e-z*z*z)**(1.0/2.0) + 1e-7)
        x = e - z*z*z - y*y
        if x < 0: continue
        m = min(m, x+y+z)
    return m

while 1:
    e = input()
    if e==0 : break
    print solve(e)

Submission status: Wrong Answer

Solution code:
def solve(e):
    m = e
    for z in range(int(e**(1/3.0))+1):
        if e-z*z*z < 0: continue
        y = int((e-z*z*z)**(1.0/2.0) + 1e-7)
        x = e - z*z*z - y*y
        m = min(m, x+y+z)
    return m

while 1:
    e = input()
    if e==0 : break
    print solve(e)

Submission status: Wrong Answer

Solution code:
while 1:
	e = input()
	if e == 0: break
	z = int(e**(1.0/3.0))
	while e - (z+1)**3 >= 0:
		z += 1
	y = int((e-z**3)**0.5)
	x = e - y**2 - z**3
	print x+y+z

Submission status: Wrong Answer

Solution code:
while 1:
	e = input()
	if e == 0: break
	z = int(e**(1.0/3.0))
	while e - (z+1)**3 >= 0: z += 1
	y = int((e-z**3)**0.5)
	y1 = int(e**0.5)
	x = e - y**2 - z**3
	x1 = e - y1**2
	print min(x+y+z,x1+y1)

Submission status: Accepted

Solution code:
import math
while 1:
    e = int(input().strip())
    if e ==0:break
    m=e
    z =0
    while z**3 <= e:
        y = int(math.sqrt(e-z**3))
        x = e - y**2- z**3 
        if x < 0:break
        if m > x+y+z: m = x+y+z    
        z+=1
    print(m)

Submission status: Accepted

Solution code:
while True:
    e = int(input())
    if e == 0:
        break
    ans = e
    z = 0
    while z**3<=e:
        y = int((e-z**3)**0.5)
        x = e-z**3-y**2  #zとyを先に定める
        ans = min(x+y+z,ans)
        z +=1
    print(ans)

Submission status: Accepted

Solution code:
from math import sqrt

while True:
    e = int(input())
    if e == 0: break
    ans = e
    for z in range(e):
        if z ** 3 > e: break
        y = int(sqrt(e - z ** 3))
        x = e - (z ** 3 + y ** 2)
        ans = min(ans, x + y + z)
    print(ans)

Submission status: Accepted

Solution code:
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        while True:
            e = input()
            if e == 0:
                break
            m = float('inf')
            for z in range(101):
                tmp = e - z ** 3
                if tmp < 0:
                    continue
                y = int(math.sqrt(tmp))
                x = e - y ** 2 - z ** 3
                m = min(m, x + y + z)
            print m
        return None

if __name__ == '__main__':
    m = Main()
    m.solve()

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from math import sqrt

while True:
    e = int(input())
    if e == 0:
        break
    ans = 10**9
    for z in range(e):
        if z**3 > e:
            break
        y = int(sqrt(e-z**3))
        x = e - y ** 2 - z ** 3
        ans = min(ans,x+y+z)
    print(ans)

Submission status: Accepted

Solution code:
from math import sqrt
while 1 :
	e = int(raw_input())
	if e == 0:
		break
	z = 0
	m = float("inf")
	while z ** 3 <= e:
		y = int(sqrt(e - z**3))
		m = min(m, e  - y**2 - z**3 + y + z)
		z += 1
	print int(m)

Submission status: Accepted

Solution code:
while(1):
    e=int(raw_input())
    if e==0:
        break
    else:
        sum=99999999999999
        for z in range(101):
            edash=e-z**3
            if edash<0:
                break
            y=int(edash**(1/2.0))
            x=edash-y**2
            if x+y+z<sum:
            	[X,Y,Z]=[x,y,z]
                sum=x+y+z
        print sum

Submission status: Accepted

Solution code:
from math import floor, sqrt

cubics = [ x * x * x for x in range(101)]
squares = [ x * x for x in range(1000)]
while True:
    m = 1000000
    e = int(input())
    if e == 0: break
    for z in range(len(cubics)):
        if e < cubics[z]: break
        tmp = e - cubics[z]
        y = floor(sqrt(tmp))
        x = tmp - y ** 2
        m = min(m, x + y + z)
    print(m)

Submission status: Accepted

Solution code:
import math

while True:
	e = int(input())
	if e == 0:
		break
	r = 1<<30
	z = 0
	while z**3 <= e:
		c = int(math.sqrt(e-z**3))
		r = min(e-z**3-c**2+c+z, r)
		z += 1
	print(r)

Submission status: Accepted

Solution code:
import math
targ = int(input())
y,z = 0,0
while True:
    minans = float("inf")
    for n in range(math.ceil(targ ** ( 1 / 3))+1):
        if minans == 0:
            break
        if targ - n**3 >= 0:
            m = int((targ - n**3) **(1/2))
        else:
            m = 0
        if (n ** 3) + (m **2) > targ:
            break
        if minans > targ - (n ** 3 + m**2) + n + m:
            minans = targ - (n ** 3 + m**2) + n + m
    if minans != float("inf"):
        print(minans)
    else:
        print(y + z)
    targ = int(input())
    if targ == 0:
        break

Submission status: Accepted

Solution code:
import math

while True:
  e = int(raw_input())
  if e==0: break
  m = 10 ** 4
  for z in xrange(10 ** 2 + 1):
    if e < z ** 3: break
    y = int(math.sqrt(e - z ** 3))
    x = e - z ** 3 - y ** 2
    m = min(m, x+y+z)
  print m

Submission status: Accepted

Solution code:
#coding: utf-8
import math

def yis(z):
    y = int(math.floor(math.sqrt(e - z * z * z)))
    return y

while True:
    e = int(raw_input())
    y = 0
    z = 0
    if e == 0:
        break
    for i in range(1000):
        if i * i * i > e:
            z = i - 1
            break
    n = z
    m = e
    for i in range(n + 1):
        y = yis(z)
        m = min(m,e - y * y - z * z * z + y + z)
        z = z - 1
    print m

Submission status: Accepted

Solution code:
#coding: utf-8
import math

def yis(z):
    y = int(math.floor(math.sqrt(e - z * z * z)))
    return y

while True:
    e = int(raw_input())
    y = 0
    z = 0
    if e == 0:
        break
    for i in range(102):
        if i * i * i > e:
            z = i - 1
            break
    n = z
    m = e
    for i in range(n + 1):
        y = yis(z)
        m = min(m,e - y * y - z * z * z + y + z)
        z = z - 1
    print m

Submission status: Accepted

Solution code:
while 1:
    e=int(input())
    if e==0:break
    m,z=10**15,0
    while z**3<=e:
        b=e-z**3
        a=int(b**0.5)
        m=min(m,b+z-a**2+a)
        z+=1
    print(m)

Submission status: Accepted

Solution code:
from math import sqrt

while True:
    e = int(input())
    if e == 0: break
    m = e
    for z in range(e):
        if z**3 > e: break
        y = int(sqrt(e - z**3))
        x = e - (y**2 + z**3)
        m = min(m, x+y+z)
    print(m)

Submission status: Accepted

Solution code:
# ??¶?´?: x + y^2 + z^3 = e
# ????????¨??§???????°???¨?????? x + y + z ????±??????????

import math

# 1. z ????±???????
# 2. y ??? ???y**2 < (e - z**3)???????????????y????????§???
# 3. x ??? e - y**2 - z**3
# ?????????e????????????????????????101???
while True:
    e = int(input())
    if e == 0:
        break

    min_e = e
    for i in range(101):
        if (e - i**3) < 0:
            break;
        z = i
        y = math.floor(math.sqrt(e - i**3))
        x = e - y**2 - z**3
        if ( (x + y + z) < min_e ):
            min_e = x + y + z

    print(min_e)

Submission status: Accepted

Solution code:
while True:
    e = int(input())
    if e == 0:
        break
    ans = float('inf')
    max_z = int(e ** (1 / 3) + 1e-6)
    for z in range(max_z, -1, -1):
        y = int((e - z ** 3) ** 0.5 + 1e-6)
        ans = min(ans, e - y ** 2 - z ** 3 + y + z)
    print(ans)

Submission status: Accepted

Solution code:
import sys

inf = 1<<30
w = 100

def solve():
    while 1:
        e = int(sys.stdin.readline().rstrip())

        if e == 0:
            return

        ans = inf

        z0 = int(e**(1/3))

        for z in range(max(0, z0 - w), z0 + w):
            if e - z**3 < 0:
                break

            y0 = int((e - z**3)**0.5)
            for y in range(max(0, y0 - w), y0 + w):
                x = e - z**3 - y**2

                if x < 0:
                    break

                ans = min(ans, x + y + z)

        print(ans)

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import sys

inf = 1<<30
lim = 10**5

def solve():
    cubics = [x**3 for x in range(100 + 1)]

    while 1:
        e = int(sys.stdin.readline().rstrip())

        if e == 0:
            return

        ans = inf

        for z, c in enumerate(cubics):
            if c > e:
                break
            y = int((e - c)**0.5)
            x = e - c - y**2
            ans = min(ans, x + y + z)

        print(ans)

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import sys

inf = 1<<30

def solve():
    while 1:
        e = int(sys.stdin.readline().rstrip())

        if e == 0:
            return

        ans = inf

        for z in range(int(e**(1/3)) + 10):
            rest = e - z**3

            if rest < 0:
                break
                
            y = int((rest)**0.5)
            x = rest - y**2

            ans = min(ans, x + y + z)

        print(ans)

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
# your code goes here
#grab
import math
e=int(input())
#e=1250
while e>0:
    z=0
    t=z**3
    f=e-t
    q=math.sqrt(f)
    y=int(q)
    if q-y>0.999999:
        y+=1
    x=y*y
    x=f-x
    m=x+y+z
    while t<=e:
        f=e-t
        q=math.sqrt(f)
        y=int(q)
        if q-y>0.999999:
            y+=1
        x=y*y
        x=f-x
        l=x+y+z
        if l<m:
            m=l
        z+=1
        t=z**3
    print(m)
    e=int(input())

Submission status: Accepted

Solution code:
while True:
    e=int(input())
    if e==0:
        break
    m=e
    z=0
    while z**3<=e:
        y=int((e-z**3)**.5)
        x=e-z**3-y**2
        m=min(m,x+y+z)
        z+=1
    print(m)

Submission status: Accepted

Solution code:
import math
while True:
    E = int(input())
    if E == 0: break
    ans = 10**10
    z = 0
    while z**3 <= E:
        y = int(math.sqrt(E - z**3))
        x = E - z**3 - y**2
        ans = min(x+y+z, ans)
        z += 1
    print(ans)

Submission status: Accepted

Solution code:
from math import sqrt

while True:
    e=int(input())
    if e==0:
        break
    m=e
    for z in range(e):
        if(z**3>e):
            break
        temp=e-z**3
        y=int(sqrt(temp))
        x=temp-y**2
        m=min(m,x+y+z)
    print(m)

Submission status: Accepted

Solution code:
import math

while True:
    e = int(input())
    if e == 0:
        break
    
    m = e + 1
    z = 0
    while z <= e:
        z3 = z ** 3
        if z3 > e:
            break
        y = int(math.sqrt(e - z3))
        x = e - y ** 2 - z3
        m = min(m, x + y + z)
        z += 1
    print(m)

Submission status: Accepted

Solution code:
def cube(x):
    i=1
    while(True):
        if i**3 >x:
            return i-1
        else:
            i +=1
            
while(True):
    e = int(input())
    if e==0:
        break
    ans = pow(10,16)    

    z_max = cube(e)
    for z in range(z_max+1):
        y = int(pow(e-z**3,1/2))
    
        ans = min(ans,e-y*y+y-z*z*z+z)
    print(ans)

Submission status: Accepted

Solution code:
from math import floor
while(True):
  e = int(input())
  if e == 0:
    quit()
  ans = e
  for i in range(0,e):
      if i ** 3 > e:
          break
      j = floor((e - i ** 3)**0.5)
      k = e - i ** 3 - j ** 2 + i + j
      if k < ans:
          ans = k
  print(ans)

Submission status: Accepted

Solution code:
import math


def solve(e):
    k = 2 ** 32
    for z in range(100, -1, -1):
        z3 = z * z * z
        if z3 > e:
            continue
        e2 = e - z3

        ylm = int(math.sqrt(e2))
        xzlm = 3 * z * z + 3 * z + 1

        for y in range(ylm, -1, -1):
            y2 = y * y
            if e2 > (y + 1) * (y + 1):
                break
            e3 = e2 - y2

            xylm = 2 * y + 1
            x = e3
            if x > xylm or x > xzlm:
                continue
            k = min(k, x + y + z)
    return k


def main():
    while True:
        a = int(input())

        if a == 0:
            break

        print(solve(a))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math


def solve(e):
    k = 2 ** 32
    for z in range(100, -1, -1):
        z3 = z * z * z
        if z3 > e:
            continue
        e2 = e - z3

        ylm = int(math.sqrt(e2))

        for y in range(ylm, -1, -1):
            y2 = y * y
            if e2 > (y + 1) * (y + 1):
                break
            e3 = e2 - y2

            x = e3
            k = min(k, x + y + z)
    return k


def main():
    while True:
        a = int(input())

        if a == 0:
            break

        print(solve(a))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
while True:
    e = int(input())
    if e == 0:
        break
    z, ans = 0, float('inf')
    while z ** 3 <= e:
        r = e - z ** 3
        y = int(r ** 0.5)
        x = r - y ** 2
        ans = min(ans, x + y + z)
        z += 1
    print(ans)

Submission status: Accepted

Solution code:
while True:
    e = int(input())
    if e == 0:
        break
    z, ans = 0, float('inf')
    for z in range(e):
        if z ** 3 > e:
            break
        else:
            r = e - z ** 3
            y = int(r ** 0.5)
            x = r - y ** 2
            ans = min(ans, x + y + z)
    print(ans)

Submission status: Accepted

Solution code:
while(1):
    e = int(input())
    if e == 0:
        break
    m, z = 10 ** 15, 0
    while z**3 <= e:
        y = int((e - z**3) ** 0.5)
        x = e - z**3 - y ** 2
        m = min(m, x + y + z)
        z += 1
    print(m)

Submission status: Accepted

Solution code:
from math import sqrt

while True:
    e = int(raw_input())

    if e == 0: break
    z, ans = 0, e

    while z ** 3 <= e:
        y = int(sqrt(e - z**3))
        x = e  - y**2 - z**3
        ans = min(ans, x + y + z)
        z += 1

    print ans

Submission status: Accepted

Solution code:
from math import floor

while True:
    e = int(input())
    if e == 0:
        break

    ans = 10 ** 10
    z = 0
    while z ** 3 <= e:
        y = floor((e - z **3) ** 0.5)
        x = e - y ** 2 - z ** 3
        ans = min(ans, x + y + z)
        z += 1
    print (ans)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

def main():
    rr = []

    while True:
        n = I()
        if n == 0:
            break
        r = n
        for i in range(n):
            t = i**3
            if t > n:
                break
            u = n - t
            s = math.floor(u**0.5)
            v = u - s**2
            tr = i + s + v
            if r > tr:
                r = tr

        rr.append(r)

    return '\n'.join(map(str, rr))


print(main())

Submission status: Accepted

Solution code:
while 1:
	e = input()
	if e == 0: break
	ans = 3*e
	for z in range(e+1):
		z3 = z**3
		if z3 > e: break
		y = int((e-z3)**0.5)
		x = e - y**2 - z3
		ans = min(ans,x+y+z)
	print ans

Submission status: Accepted

Solution code:
while 1:
    e = ans = input()
    if e == 0: break
    for z in range(e):
        z3 = z**3
        if z3 > e: break
        y = int((e-z3)**0.5)
        ans = min(ans,e+y+z-y**2-z3)
    print ans

Submission status: Accepted

Solution code:
while 1:
	e = ans = input()
	if e == 0: break
	for z in range(e):
		z3 = z**3
		if z3 > e: break
		y = int((e-z3)**0.5)
		ans = min(ans,e+y+z-y**2-z3)
	print ans