Page 5 of 5

Re: 11428 - Cubes

Posted: Thu Sep 04, 2014 7:39 pm
by brianfry713
I changed it to use my code and critical input at:
http://www.udebug.com/UVa/11428

Re: 11428 - Cubes

Posted: Thu Jan 08, 2015 1:21 pm
by uradura
why wa????????????????????? :oops: :oops: :oops: :oops: :oops: :oops: :oops:
http://ideone.com/QBwkso

Re: 11428 - Cubes

Posted: Fri Jan 09, 2015 12:22 am
by brianfry713
uradura on 11428 (r|d) for input 6487 print 47 46

Re: 11428 - Cubes

Posted: Sun Feb 08, 2015 11:34 pm
by xnorax
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");
    }

Re: 11428 - Cubes

Posted: Tue Feb 10, 2015 1:43 am
by brianfry713
Input 26 AC output 3 1.
Add a } to the end of your code.
Try solving it without using floating point.