UVA Solution : 386 Perfect Cubes

Solve in C:


#include<stdio.h>
#include<math.h>
int main()
{
    int i,j,k,m,n,a,b,c,flag,s,count;

    for(s=1; s<=200; s++)
    {
        m=s*s*s;
        for(i=2; i<=200; i++)
        {
            a=i*i*i;
            for(j=i+1; j<=200; j++)
            {
                b=j*j*j;
                for(k=j+1;k<=200;k++)


        {
            c=k*k*k;
            if(m==(a+b+c))
            {
                printf("Cube = %d, Triple = (%d,%d,%d)\n",s,i,j,k);
            }
        }
            }

        }
    }
    return 0;

    }






No comments

Most View Post

Recent post

Codeforces Round 925 (Div. 3) 1931D. Divisible Pairs Solution

    Problem Link  :   https://codeforces.com/contest/1931/problem/D S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. ...

Powered by Blogger.