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]

Post by brianfry713 »

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]

Post by mathgirl »

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]

Post by uDebug »

Replying to follow the thread.
Check input and AC output for over 7,500 problems on uDebug!

Find us on Facebook. Follow us on Twitter.

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

why getting WA?? Help me plzz

Post by sady »

:cry: :cry: :cry: :cry: :cry: :cry:

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

Post 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)
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman

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

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

Post 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:

lighted
Guru
Posts: 587
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

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

Post by lighted »

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

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

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

Post by sady »

Subhan-Allah After making double to int as you said i got accepted. :P
You are e genius lighted. :o :D

lighted
Guru
Posts: 587
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

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

Post by lighted »

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

Post Reply

Return to “Volume 3 (300-399)”