Re: 11428 - Cubes
Posted: Thu Sep 04, 2014 7:39 pm
I changed it to use my code and critical input at:
http://www.udebug.com/UVa/11428
http://www.udebug.com/UVa/11428
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");
}