I changed it to use my code and critical input at:
http://www.udebug.com/UVa/11428
11428 - Cubes
Moderator: Board moderators
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 11428 - Cubes
Check input and AC output for thousands of problems on uDebug!
-
- 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!
Re: 11428 - Cubes
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
![:-?](./images/smilies/icon_confused.gif)
![:(](./images/smilies/icon_frown.gif)
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");
}
-
- 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.
Add a } to the end of your code.
Try solving it without using floating point.
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!