CubeSum
TCO04 Wildcard · 2004-09-07 · by lars2520
TCO04 Wildcard · 2004-09-07 · by lars2520 · Math
Problem Statement
Problem Statement
Given an int , N, return the number of ways to represent N as the sum of 4 non-negative perfect cubes. Do not count different permutations of the same 4 cubes more than once. For example, (0,0,0,1) is the same as (1,0,0,0).
Constraints
- N will be between 1 and 100,000,000, inclusive.
Examples
0)
100000000 Returns: 43
1)
1 Returns: 1
Keep in mind that 0 is a perfect cube so 1 can be represented as 0+0+0+1
2)
4 Returns: 1
1+1+1+1 = 4
3)
2072 Returns: 4
0 + 1 + 7*7*7* + 12*12*12 = 0 + 1 + 343 + 1728 = 2072 0 + 7*7*7 + 9*9*9 + 10*10*10 = 0 + 343 + 729 + 1000 = 2072 2*2*2 + 4*4*4 + 10*10*10 + 10*10*10 = 8 + 64 + 1000 + 1000 = 2072 4*4*4 + 4*4*4 + 6*6*6 + 12*12*12 = 64 + 64 + 216 + 1728 = 2072
4)
98765432 Returns: 24
Submissions are judged against all 154 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Coding Area
Language: C++17 · define a public class CubeSum with a public method int count(int N) · 154 test cases · 2 s / 256 MB per case