题解 | #汽水瓶#
汽水瓶
https://www.nowcoder.com/practice/fe298c55694f4ed39e256170ff2c205f
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; import java.util.ArrayList; import java.util.Scanner; public class Main { public static void main(String[] args) throws IOException{ Scanner in = new Scanner(System.in); while (in.hasNext()) { int n = in.nextInt(); int m = 0; int x = 0; if(n==0) { break; } while (n >= 3) { m = n / 3; n = n - 2 * m; x += m; } if (n % 3 == 2) { x += 1; } System.out.println(x); } } }