The equation A**5 + B**5 + C**5 + D**5 + E**5 = F**5 has exactly one integral so
ID: 3622971 • Letter: T
Question
The equation A**5 + B**5 + C**5 + D**5 + E**5 = F**5 has exactly oneintegral solutions that satisfies 0 < A <= B <= C <= D <= E <= F <= 75. Write
a program to find the solution. Hint: First, precompute all values of X**5 and
store them in an array. Then, for each tuple (A, B, C, D, E), you will only
need to verify that some F exists in the array. (There are several ways to check
for F, one of which is to use a binary search to check for F. Other methods
might prove to be more efficient.)
Explanation / Answer
//Try to execute in 64 or 32 bit operating system...
#include <stdio.h>
#include <limits.h>
#include<math.h>
long a[75];
int binerySearch(long keynum)
{
int low=1;
int high=75;
int mid;
do
{
mid= (low + high) / 2;
if ( keynum < a[mid] )
high = mid - 1;
else if ( keynum > a[mid])
low = mid + 1;
} while( keynum!=a[mid] && low <= high);
if( keynum == a[mid] )
{
return mid;
}
else
{
return -1;
}
}
int main()
{
int i,j,k,l,m;
for(i=1;i<=75;i++)
{
a[i]=pow(i,5);
}
for(i=1;i<=75;i++)
{
for(j=i;j<=75;j++)
{
for(k=j;k<=75;k++)
{
for(l=k;l<=75;l++)
{
for(m=l;m<=75;m++)
{
if(binerySearch(a[i]+a[j]+a[k]+a[l]+a[m])!=-1)
{
printf("Numbers are %d**5+%d**5+%d**5+%d**5+%d**5=%d**5",i,j,k,l,m,binerySearch(a[i]+a[j]+a[k]+a[l]+a[m]));
}
}
}
}
}
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.