import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
public class Main {
public static void main(String[] args) throws IOException {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
StringBuffer sb = new StringBuffer("");
String m = "";
int n=Integer.parseInt(br.readLine());
for(int i=0;i<n;i++) {
int x=Integer.parseInt(br.readLine());
sb.append("Case ").append((i+1)).append(":");
intCheck(x, sb);
}
System.out.print(sb);
}
static void intCheck(int x,StringBuffer sb) {
LinkedList<Integer> list=new LinkedList<Integer>();
for(int i=1;i*i<x;i++){
long ans=x-i*i;
long anssq=ans*ans;
if((anssq)%(x-ans)==0)
list.add(x-(i*i));
}
for(int i=list.size()-1;i>-1;i--){
sb.append(" ").append(list.get(i));
}
sb.append("\n");
}
}
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
public class Main {
public static void main(String[] args) throws IOException {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
StringBuffer sb = new StringBuffer("");
String m = "";
int n=Integer.parseInt(br.readLine());
for(int i=0;i<n;i++) {
int x=Integer.parseInt(br.readLine());
sb.append("Case ").append((i+1)).append(":");
intCheck(x, sb);
}
System.out.print(sb);
}
static void intCheck(int x,StringBuffer sb) {
LinkedList<Integer> list=new LinkedList<Integer>();
for(int i=1;i*i<x;i++){
long ans=x-i*i;
long anssq=ans*ans;
if((anssq)%(x-ans)==0)
list.add(x-(i*i));
}
for(int i=list.size()-1;i>-1;i--){
sb.append(" ").append(list.get(i));
}
sb.append("\n");
}
}
No comments:
Post a Comment