分析:对等式变型可得y的范围在k到2k之间,暴力。
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while (scanner.hasNext()) {
int k = scanner.nextInt();
List<String> list = new ArrayList<>();
for (int y = k + 1; y <= 2 * k; y++) {
int dividend = k * y;
int divisor = y - k;
if (dividend % divisor == 0) {
int x = dividend / divisor;
String string = "1/" + k + " = " + "1/" + x + " + " + "1/" + y;
list.add(string);
}
}
System.out.println(list.size());
for (String string : list) {
System.out.println(string);
}
}
}
}