Fazil
Member •
Apr 22, 2009
My Program found 4 results. First three found with in 1 Min 48 seconds. Total scan took 7 Min 19 seconds.
Result:
{0, 0, 1} - 0 Sec
{450, 4500, 5050} - 6 Sec
{7350, 6000, 6650} - 1 Min 48 Sec
{27150, 1500, 1350} - 6 Min 24 Sec
Program:
void main()
{
unsigned long double LHS, RHS, Duration;
int a, b, c, Left, Right;
time_t Start, Stop;
time( &Start );
for( a = 0; a < 31427; a++ )
{
for( b = 0; b < 31427; b++ )
{
Left = 0;
Right = 31428;
while( Left < ( Right - 1 ))
{
c = ( Left + Right ) / 2;
LHS = unsigned long double(a) * 987654321;
LHS += unsigned long double(b) * 123456789;
LHS += unsigned long double(c);
RHS = unsigned long double( a + b + c );
RHS = RHS * RHS * RHS;
if( LHS == RHS )
{
printf("\n\n987654321*%d + 123456789*%d + %d = %.0Lf\n", a, b, c, LHS);
printf("(%d + %d + %d)^3 = %.0Lf\n", a, b, c, RHS);
printf("987654321*%d + 123456789*%d + %d = (%d + %d + %d)^3\n\n", a, b, c, a, b, c);
break;
}
if( LHS < RHS )
{
Right = c;
}
else
{
Left = c;
}
}
}
time( &Stop );
Duration = difftime( Stop, Start );
int Seconds = (int)fmod( Duration, 60 );
int Minutes = (int)fmod( floor(Duration / 60), 60 );
int Hours = int(Duration / 3600);
printf("\rCompleted:%0.1Lf%%", (a * 100.) / 31427);
printf("\tElapsed Time:%02d:%02d:%02d", Hours, Minutes, Seconds);
}
}
Output:
987654321*0 + 123456789*0 + 1 = 1
(0 + 0 + 1)^3 = 1
987654321*0 + 123456789*0 + 1 = (0 + 0 + 1)^3
Completed:1.4% Elapsed Time:00:00:06
987654321*450 + 123456789*4500 + 5050 = 1000000000000
(450 + 4500 + 5050)^3 = 1000000000000
987654321*450 + 123456789*4500 + 5050 = (450 + 4500 + 5050)^3
Completed:23.4% Elapsed Time:00:01:48
987654321*7350 + 123456789*6000 + 6650 = 8000000000000
(7350 + 6000 + 6650)^3 = 8000000000000
987654321*7350 + 123456789*6000 + 6650 = (7350 + 6000 + 6650)^3
Completed:86.4% Elapsed Time:00:06:24
987654321*27150 + 123456789*1500 + 1350 = 27000000000000
(27150 + 1500 + 1350)^3 = 27000000000000
987654321*27150 + 123456789*1500 + 1350 = (27150 + 1500 + 1350)^3
Completed:100.0% Elapsed Time:00:07:19
Are you sure? This action cannot be undone.