回溯法解决问题,代码简单易懂 import java.util.*; public class Main{ public static void main(String[] args){ Scanner scan=new Scanner(System.in); while(scan.hasNextInt()){ int n=scan.nextInt(); ...