题解 | #汽水瓶#
汽水瓶
http://www.nowcoder.com/practice/fe298c55694f4ed39e256170ff2c205f
import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); while (in.hasNextInt()) { int v = in.nextInt(); int r = heqishui(v); if (r != 0) System.out.println(r); } } public static int heqishui(int num) { int count = 0; while (num >= 3) { // 本轮剩余 int remain = 0; count += num / 3; if (num > 3) { remain = num % 3; } num = num / 3 + remain; if (num == 2) { num += 1; } } return count; } }