11428 - Cubes

All about problems in Volume 114. 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: 11428 - Cubes

Post by brianfry713 » Thu Sep 04, 2014 7:39 pm

I changed it to use my code and critical input at:
http://www.udebug.com/UVa/11428
Check input and AC output for thousands of problems on uDebug!

uradura
New poster
Posts: 11
Joined: Thu Jan 01, 2015 10:31 am

Re: 11428 - Cubes

Post by uradura » Thu Jan 08, 2015 1:21 pm

why wa????????????????????? :oops: :oops: :oops: :oops: :oops: :oops: :oops:
http://ideone.com/QBwkso

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11428 - Cubes

Post by brianfry713 » Fri Jan 09, 2015 12:22 am

uradura on 11428 (r|d) for input 6487 print 47 46
Check input and AC output for thousands of problems on uDebug!

xnorax
New poster
Posts: 9
Joined: Thu Jun 26, 2014 9:31 pm

Re: 11428 - Cubes

Post by xnorax » Sun Feb 08, 2015 11:34 pm

My code solves 397 & 721 but I'm getting WA! :-? Please help! :(

My Algo:
starting form x=2,y=1 if x^3 - y^3 < N
x++,y++

if x^3 - y^3 == N print x and y
else no solution

Code: Select all


#include <iostream>
#include <math.h>
using namespace std;

int main(){
     long long int x,y,n,res=0,prev=0;
    while (cin>>n) {
        prev=0;
        if (n==0) break;
        
            for ( x=1,y=0; prev<n; ) {
            x++;y++;
            res=pow(x, 3)-pow(y, 3);
                prev=res;}
        if (prev==n)
            printf("%i %i\n",x,y);
        else
            printf("No solution\n");
    }

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11428 - Cubes

Post by brianfry713 » Tue Feb 10, 2015 1:43 am

Input 26 AC output 3 1.
Add a } to the end of your code.
Try solving it without using floating point.
Check input and AC output for thousands of problems on uDebug!

Post Reply

Return to “Volume 114 (11400-11499)”