UVA 11428 Cubes Solution
Solve in C:
#include<stdio.h>
#include<math.h>
int main()
{
long long int i,j,m,n,a,k,count=0;
while(scanf("%lld",&n)!=EOF)
{
if(n==0)
break;
count=0;
a=sqrt(n);
{
for(i=1; i<=a; i++)
{
for(j=0; j<=i; j++)
{
if(((i*i*i)-(j*j*j))==n)
{
count++;
m=i,k=j;
break;
}
}
if(count==1)
break;
}
if(count==1)
printf("%lld %lld\n",m,k);
else
printf("No solution\n");
}
}
}
#include<stdio.h>
#include<math.h>
int main()
{
long long int i,j,m,n,a,k,count=0;
while(scanf("%lld",&n)!=EOF)
{
if(n==0)
break;
count=0;
a=sqrt(n);
{
for(i=1; i<=a; i++)
{
for(j=0; j<=i; j++)
{
if(((i*i*i)-(j*j*j))==n)
{
count++;
m=i,k=j;
break;
}
}
if(count==1)
break;
}
if(count==1)
printf("%lld %lld\n",m,k);
else
printf("No solution\n");
}
}
}
No comments