11428:Cubes
問題文
http://uva.onlinejudge.org/external/114/11428.html
N=(xの3乗根)-(yの3乗根)となるようなx,yの中でyが最小のものを求めよ。
全部試した。
#include<iostream> #include<algorithm> using namespace std; int main(void){ int n; while(cin >> n,n){ for(int y=1;y<101;y++){ for(int x=y;x<101;x++){ if(x*x*x-y*y*y==n){ cout << x << " " << y << endl; goto end; } } } cout << "No solution" << endl; end:; } return 0; }