import java.util.*;
import java.io.*;
public class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String str="";
while(!(str=br.readLine()).equals("0")){
Box box=new Box(0,Integer.parseInt(str));
System.out.println(checkBox(box).drinkBox);
}
}
public static Box checkBox(Box box){
if (box.emptyBox<2){
return box;
}else if (box.emptyBox==2){
box.drinkBox++;
box.emptyBox=0;
return box;
}else{
box.drinkBox=box.drinkBox+box.emptyBox/3;
box.emptyBox=box.emptyBox%3+box.emptyBox/3;
Box box1 = checkBox(box);
return box1;
}
}
static class Box{
private Integer drinkBox;
private Integer emptyBox;
public Box(int drinkBox,int emptyBox){
this.drinkBox=drinkBox;
this.emptyBox=emptyBox;
}
}
}
HJ22 汽水瓶
最新推荐文章于 2023-01-31 10:56:44 发布