## Assignment:

You have a number x – find a couple of pairs that can represent x as a sum of two cubes.

Example:

or

or

or

This would be the solutions to the Diophantine equation,

Any number x that satisfies the demand will have two pairs and such that and are all less than . We should create an additional array of size . Every index in the array will contain the value that equals to the cube of . Now the problem reduces to the search of the pair of elements in the sorted array whose sum is equal to given .

C++ implementation:

#include <iostream> #include <cmath> using namespace std; void searchPairs(int n) { int root = pow(n, 1.0 / 3.0); int *cube = new int[root + 1]; for (int i = 1; i <= root; i++) cube[i] = i*i*i; int a = 1; int b = root; while (a < b) { if (cube[a] + cube[b] < n) a++; else if (cube[a] + cube[b] > n) b--; else { cout << "(" << a << ", " << b << ")" << endl; a++; b--; } } } int main() { int n = 0; cout << "Input the number you want to check: \n"; cin >> n; searchPairs(n); system("pause"); return 0; }

Screenshots of the working program:

The presented piece of writing is a sample assignment for the solution of the problem of the sum of two cubes. You can also be interested in our quicksort example. We wish to remind you that you are not allowed to use any of the information contained within or parts of the assignments themselves which are posted on our blog without proper references to the source, since it will be considered as a violation of the author’s rights, and thus plagiarism. More than that, it’s a very ineffective way of dealing with your academic problems, because you can place an order and simply wait until our professionals work on your assignment.

To place an order, first fill in the short order form at the top of the page, where you need to provide your e-mail and the discipline of your assignment. After that, you will be taken to the page with a more detailed form. Specify your requirements, upload any additional files and wait for our experts to start bidding for your order. You can choose an expert you like after reviewing his or her personal profile. A typical expert’s profile contains information about the previous orders, average rating and feedback from customers. Choose the one who is the best fit for solving your sum of two cubes problem and wait for the paper to be done for you. Learning will become easy with our experts!