386 - Perfect Cubes
Moderator: Board moderators
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 386 - Perfect Cubes [WA]
Your code is printing a line with a=9 and has other errors.
Check input and AC output for thousands of problems on uDebug!
Re: 386 - Perfect Cubes [WA]
Ah!. My mistake. I did not see that a,b,c > 1. I changed the starting value to 2 and got AC.
why getting WA?? Help me plzz
Last edited by sady on Wed Aug 06, 2014 4:18 pm, edited 1 time in total.
Re: 386:WA: Help me plzzzzzzzzzzzzzzzzzz....
It is not correct to compare double and long directly.
You can solve this problem with integers without double.
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)](./images/smilies/icon_cool.gif)
You can solve this problem with integers without double.
![:)](./images/smilies/icon_smile.gif)
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);
}
}
Don't forget to remove your code after getting accepted.
![8)](./images/smilies/icon_cool.gif)
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
Re: 386:WA: Help me plzzzzzzzzzzzzzzzzzz....
thanks lightedIt is not correct to compare double and long directly.
You can solve this problem with integers without double.![]()
![:D](./images/smilies/icon_biggrin.gif)
a few minutes ago i did find my mistake after hours of hard work.
![:lol:](./images/smilies/icon_lol.gif)
But still wrong answer.
![:cry:](./images/smilies/icon_cry.gif)
![:cry:](./images/smilies/icon_cry.gif)
![:cry:](./images/smilies/icon_cry.gif)
![:cry:](./images/smilies/icon_cry.gif)
![:cry:](./images/smilies/icon_cry.gif)
![:cry:](./images/smilies/icon_cry.gif)
![:cry:](./images/smilies/icon_cry.gif)
![:cry:](./images/smilies/icon_cry.gif)
![:cry:](./images/smilies/icon_cry.gif)
![:cry:](./images/smilies/icon_cry.gif)
![:cry:](./images/smilies/icon_cry.gif)
Re: 386:WA: Help me plzzzzzzzzzzzzzzzzzz....
I got accepted by making changes above. You can post your updated code. ![:)](./images/smilies/icon_smile.gif)
![:)](./images/smilies/icon_smile.gif)
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
Re: 386:WA: Help me plzzzzzzzzzzzzzzzzzz....
Subhan-Allah After making double to int as you said i got accepted.
You are e genius lighted.
![:D](./images/smilies/icon_biggrin.gif)
![:P](./images/smilies/icon_razz.gif)
You are e genius lighted.
![:o](./images/smilies/icon_eek.gif)
![:D](./images/smilies/icon_biggrin.gif)
Re: 386:WA: Help me plzzzzzzzzzzzzzzzzzz....
Alhamdulillah! ![:D](./images/smilies/icon_biggrin.gif)
![:D](./images/smilies/icon_biggrin.gif)
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman