Page 4 of 4

Re: 386 - Perfect Cubes [WA]

Posted: Fri Jun 01, 2012 12:26 am
by brianfry713
Your code is printing a line with a=9 and has other errors.

Re: 386 - Perfect Cubes [WA]

Posted: Fri Jun 01, 2012 6:25 am
by mathgirl
Ah!. My mistake. I did not see that a,b,c > 1. I changed the starting value to 2 and got AC.

Re: 386 - Perfect Cubes [WA]

Posted: Thu Jun 19, 2014 2:33 pm
by uDebug
Replying to follow the thread.

why getting WA?? Help me plzz

Posted: Wed Aug 06, 2014 9:42 am
by sady
:cry: :cry: :cry: :cry: :cry: :cry:

Code: Select all

 removed after AC

Re: 386:WA: Help me plzzzzzzzzzzzzzzzzzz....

Posted: Wed Aug 06, 2014 3:22 pm
by lighted
It is not correct to compare double and long directly.
You can solve this problem with integers without double. :)

Code: Select all

int cubic_root;
..
..
if( cubic[a] <= cubic[b] + cubic[c])break;
else
{
    cubic_root = cbrt( cubic[a]- cubic[b] - cubic[c] ) + 1e-6;
    if(cubic[cubic_root]==cubic[a]- cubic[b] - cubic[c] && cubic_root>c)
    {
        printf("Cube = %d, Triple = (%d,%d,%d)\n", a, b, c, cubic_root);
    }
}
By the way break after printf was wrong, there maybe additional correct solutions for bigger values of c.

Don't forget to remove your code after getting accepted. 8)

Re: 386:WA: Help me plzzzzzzzzzzzzzzzzzz....

Posted: Wed Aug 06, 2014 3:52 pm
by sady
It is not correct to compare double and long directly.
You can solve this problem with integers without double. :)
thanks lighted :D
a few minutes ago i did find my mistake after hours of hard work. :lol:

But still wrong answer. :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry:

Re: 386:WA: Help me plzzzzzzzzzzzzzzzzzz....

Posted: Wed Aug 06, 2014 4:04 pm
by lighted
I got accepted by making changes above. You can post your updated code. :)

Re: 386:WA: Help me plzzzzzzzzzzzzzzzzzz....

Posted: Wed Aug 06, 2014 4:17 pm
by sady
Subhan-Allah After making double to int as you said i got accepted. :P
You are e genius lighted. :o :D

Re: 386:WA: Help me plzzzzzzzzzzzzzzzzzz....

Posted: Wed Aug 06, 2014 4:24 pm
by lighted
Alhamdulillah! :D