Thursday, April 14, 2011

11428 - Cubes


#include<stdio.h>
#include<math.h>
int main()
{
    long s,n,x,y,z;
    freopen("in.txt","r",stdin);

    while(scanf("%ld",&n)&&n)
    {
        for(y=0;y<60;y++)
        {
            z=y*y*y+n,s=0;
            x=pow(z,1.0/3)+0.5;
            if(x*x*x==z)
            {
                s=1;
                break;
            }
        }
        if(s)
            printf("%ld %ld\n",x,y);
        else
            printf("No solution\n");
    }
    return 0;
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.