题解 | #大于5的数与3和4的关系#
进制转换
http://www.nowcoder.com/practice/8f3df50d2b9043208c5eed283d1d4da6
import java.util.*;
public class Main { public static int value = Integer.MAX_VALUE; public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); ToDo(n,0,0); System.out.println("minvalue is :"+value); } public static void ToDo(int n,int N3,int N4){ if(n<10){ switch(n){ case 9: N3+=3; break; case 8: N4+=2; break; case 7: break; case 6: N3+=2; break; } value = Math.min(value,Math.abs(N3-N4)); return; } if(N3>=N4){ ToDo(n-4,N3,N4+1); }else{ ToDo(n-3,N3+1,N4); } } }