终于来到简单题
if(N==1024) {System.out.println(0);return;}
注意最后 return 返回
import java.util.Scanner; import java.util.*; public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); if(N==1024) {System.out.println(0);return;} int res = find(1024-N,64); System.out.println(res); } public static int find(int money, int element){ if(money-element == 0) return 1; if(money-element<0) return find(money,element/4); else { return 1+find(money-element,element); } } }