## 386 - Perfect Cubes

All about problems in Volume 3. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

brianfry713
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!
mathgirl
New poster
Posts: 36
Joined: Tue Apr 24, 2012 6:20 pm

### 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.
uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

### Re: 386 - Perfect Cubes [WA]

Check input and AC output for over 7,500 problems on uDebug!

New poster
Posts: 17
Joined: Sat Dec 07, 2013 8:00 am

### why getting WA?? Help me plzz

Code: Select all

`````` removed after AC
``````
Last edited by sady on Wed Aug 06, 2014 4:18 pm, edited 1 time in total.
lighted
Guru
Posts: 587
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

### 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.

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.
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
New poster
Posts: 17
Joined: Sat Dec 07, 2013 8:00 am

### 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.
thanks lighted
a few minutes ago i did find my mistake after hours of hard work.

But still wrong answer.
lighted
Guru
Posts: 587
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

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

I got accepted by making changes above. You can post your updated code.
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
New poster
Posts: 17
Joined: Sat Dec 07, 2013 8:00 am

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

Subhan-Allah After making double to int as you said i got accepted.
You are e genius lighted.
lighted
Guru
Posts: 587
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

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

Alhamdulillah!
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman