#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
int N, x, y, j, m;
while(cin >> N){
if(N == 0)break;m = 0;
for(j = 1; j <= 60; j++){
for(int i = 1; i <= 60; i++)
if((i * i * i) - (j * j * j) == N){
x = i; y = j; m = 1; break;
}
if(m == 1)break;
}
if(j == 61)cout << "No solution" << endl;
else cout << x << " " << y << endl;
}
return 0;
}
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
int N, x, y, j, m;
while(cin >> N){
if(N == 0)break;m = 0;
for(j = 1; j <= 60; j++){
for(int i = 1; i <= 60; i++)
if((i * i * i) - (j * j * j) == N){
x = i; y = j; m = 1; break;
}
if(m == 1)break;
}
if(j == 61)cout << "No solution" << endl;
else cout << x << " " << y << endl;
}
return 0;
}
No comments:
Post a Comment