import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringBuffer sb = new StringBuffer("");
int[]cubes=new int[60];
for(int i=1;i<60;i++){
cubes[i]=i*i*i;
}
HashMap<Integer,String> hm=new HashMap<Integer, String>();
for(int i=1;i<60;i++){
for(int j=1;j<i;j++){
int temp=cubes[i]-cubes[j];
if(!hm.containsKey(temp)){
hm.put(temp,i+" "+j);
}
}
}
while(true){
int x=Integer.parseInt(br.readLine());
if(x==0)
break;
if(hm.containsKey(x)){
sb.append(hm.get(x)).append("\n");
}else{
sb.append("No solution\n");
}
}
System.out.print(sb);
}
}
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringBuffer sb = new StringBuffer("");
int[]cubes=new int[60];
for(int i=1;i<60;i++){
cubes[i]=i*i*i;
}
HashMap<Integer,String> hm=new HashMap<Integer, String>();
for(int i=1;i<60;i++){
for(int j=1;j<i;j++){
int temp=cubes[i]-cubes[j];
if(!hm.containsKey(temp)){
hm.put(temp,i+" "+j);
}
}
}
while(true){
int x=Integer.parseInt(br.readLine());
if(x==0)
break;
if(hm.containsKey(x)){
sb.append(hm.get(x)).append("\n");
}else{
sb.append("No solution\n");
}
}
System.out.print(sb);
}
}
No comments:
Post a Comment