Sunday, June 19, 2016

uva 11428 solution

Unknown
#include<cstdio>
#include<cmath>
using namespace std;

int main()
{
    int n,cube[70];
    for (int i=0;i<60;i++) cube[i]=i*i*i;
    while (scanf("%d",&n)!=EOF)
    {
        if (n==0) break;
        int i,j,flag=0;
        for (i=0;i<59;i++)
        {
            for (j=i+1;j<60;j++)
                if (cube[j]-cube[i]==n)
                {
                    flag=1;
                    goto print;
                }
        }
        print:
            if (flag) printf("%d %d\n",j,i);
            else printf("No solution\n");
    }
    return 0;
}

Unknown

Studying at Shahjalal University of Science and Technology, Sylhet.

0 comments:

Post a Comment

Coprights @ 2016,