Perfect Cubes
Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 2413 Accepted Submission (s): 1061
Problem descriptionfor Hundreds of years Fermat ' s Last theorem, which stated simply "for n > 2 there exist no Integ ERs A, B, C > 1 such that a^n = B^n + C^n, have remained elusively unproven. (A recent proof is believed to being correct, though it is still undergoing scrutiny.) It is possible, however, to find integers greater than 1 that satisfy the ' perfect cube ' equation a^3 = b^3 + c^3 + d^3 (e.g. a quick calculation would show that the equation 12^3 = 6^3 + 8^3 + 10^3 is indeed true). This problem requires so you write a program to find all sets of the numbers {A, B, C, d} which satisfy this equation for a <= 200.
Outputthe output should is listed as shown below, one perfect cube per line, in non-decreasing order of a (i.e. the lines Should is sorted by their a values). The values of B, C, and D should also is listed in non-decreasing order on the line itself. There do exist several values of a which can is produced from multiple distinct sets of B, C, and D triples. In these cases, the triples and the smaller B values should be listed first.
The first part of the output was shown here:
Cube = 6, Triple = (3,4,5)
Cube = Triple = (6,8,10)
Cube = Triple = (2,12,16)
Cube = Triple = (9,12,15)
Cube = +, Triple = (3,10,18)
Cube =, Triple = (7,14,17)
Cube = Triple = (12,16,20)
Note:the programmer would need to being concerned with an efficient implementation. The official time limit for this problem is 2 minutes, and it was indeed possible to write a solution to this problem which Executes in under 2 minutes to a MHz 80386 machine. Due to the distributed nature of the contest in this region, judges has been instructed to make the official time limit A T their site the greater of 2 minutes or twice the time taken by the judge ' s solution on the machine being used to judge T His problem.
Pay attention to the output format! There are spaces! At that time Cube dozen into cude simply can't see!!!
#include <iostream>using namespace Std;int main () {int i,j,k,m;for (i=2;i<=200;i++) for (j=2;j<=i;j++) for (k =j+1;k<=i;k++) for (m=k+1;m<=i;m++) {if ((i*i*i) = = (j*j*j+k*k*k+m*m*m)) {printf ("Cube =%d, Triple = (%d,%d,%d) \ n", I,J,K,M);} } return 0;}
Hangzhou Electric HDU ACM 1334 Perfect Cubes