题解 | #汽水瓶#
汽水瓶
http://www.nowcoder.com/practice/fe298c55694f4ed39e256170ff2c205f
//JAVA 递归 import java.util.*; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); while(sc.hasNext()){ int n = sc.nextInt(); if(0 == n){ return; } System.out.println(getClass(n)); } } public static int getClass(int n){ if(n == 1){ return 0; }else if(n == 2){ return 1; }else{ int a = n%3; int count = n/3; n = a + count; return count += getClass(n); } } }