Update appNew update is available. Click here to update.
sidenav-btnClose
Topic list
Cube Sum Pairs
EASY
15 mins
86 upvotes
Other topics
Problem solved
Badge
Skill meter
Strings
-
-
Matrices (2D Arrays)
-
-
Linked List
-
-
Sorting
-
-
Binary Search
-
-
Stacks & Queues
-
-
Trees
-
-
Graph
-
-
Dynamic Programming
-
-
Greedy
-
-
Tries
-
-
Arrays
-
-
SQL
-
-
Binary Search Trees
-
-
Heap
-
-
Bit Manipulation
-
-
Solve problems & track your progress
Checkout your overall progress in every topic here
Become
userLevel
Sensei
in DSA topics
Open the topic and solve more problems associated with it to improve your skills
Check out the skill meter for every topic
See how many problems you are left with to solve for cracking any stage. Score more than zero to get your progress counted.

Cube Sum Pairs

Contributed by
Priyaraj Sharma
Easy
yellow-spark
0/40
Avg time to solve 15 mins
Success Rate 85 %
Share
86 upvotes

Problem Statement

You are given a positive integer N, and you have to find the number of ways to represent N as a sum of cubes of two integers(let’s say A and B), such that:

N = A^3 + B^3.

Note:

1. A should be greater than or equal to one (A>=1).
2. B should be greater than or equal to zero (B>=0).
3. (A, B) and (B, A) should be considered different solutions, if A is not equal to B, i.e (A, B) and (B, A) will not be distinct if A=B.
Detailed explanation ( Input/output format, Notes, Constraints, Images )
Sample Input 1:
1
9
Sample Output 1:
2
Explanation For Sample Input 1:
There are 2 ways to represent N in the (A^3 + B^3) form ie. {(1, 2), (2, 1)}.
Eg. 1^3 + 2^3 = 9 and 2^3 + 1^3 = 9. 
Sample Input 2:
1
27
Sample Output 2:
1
Explanation For Sample Input 2:
There is only 1 way to represent N in the (A^3 + B^3) form ie. {(3, 0)}.
Eg. 3^3 + 0^3 = 27.
Reset Code
Full screen
Auto
copy-code
Console