sumofcubes ( n ): if n == 0 : retu sumofcubes (n - ( int (n ** ( 1 / 3 ))) ** 3 ) print (( int (n ** ( 1 / 3 )) ** 3 ), end = '' ') sumofcubes ( int span> ( input ())) Important! The task should be solved by a recurrent function.
The task is to represent a natural number in the form of the sum of cubes of other natural numbers, and the smallest possible number of terms should be.
INTRODUCTION: 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 2EAL 216
Introduction: 100
Conclusion: 1 8 27 64
The site that this code is sent reports on incorrect answers.
the program should deduce the number transferred to it in the form of the sum of cubes of other natural numbers. This amount should consist of the smallest amount of terms among all such amounts.
question@mail.ru
·
01.01.1970 03:00
The amount of cubes with recursion - finding the best amount of cubes
answer@mail.ru
·
01.01.1970 03:00
DeF max_cube ( n: int span> )-& gt; int : retu int (n ** ( 1 / 3 )) ** 3 def sum_of_cubes ( n ): if n == 0 : retu> [ 0 ] if n == 1 : retu [ 1 ] m = max_cube (n) . [M]+Sum_OF_Cubes (n-m) if ( len (res) & gt; 1 ) and ( 0 in res): res.remove ( 0 ) r retu resn = 10 ** 10 res = sum_of_cubes (n) print (res)