## 11428 - Cubes

Moderator: Board moderators

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

### Re: 11428 - Cubes

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!

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

### Re: 11428 - Cubes

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

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

### Re: 11428 - Cubes

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

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

Input 26 AC output 3 1.