UVa 386 - Perfect Cubes

#include<stdio.h>
int main()
{
    int a,b,c,d,m,n,o,p;
    for(a=2; a<=200; a++)
    {
        m=a*a*a;
        for(b=2; b<=200; b++)
        {
            n=b*b*b;
            if(m<n)
                break;
            for(c=b; c<=200; c++)
            {
                o=c*c*c;
                if(m<n+o)
                    break;
                for(d=c; d<=200; d++)
                {
                    p=d*d*d;
                    if(m<n+o+p)
                        break;
                    if(m==n+o+p)
                    {
                        printf("Cube = %d, ",a);
                        printf("Triple = (%d,%d,%d)\n",b,c,d);
                    }
                }
            }
        }
    }
    return 0;
}
Share on Google Plus

About Unknown

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 মন্তব্য(গুলি):

একটি মন্তব্য পোস্ট করুন