UVA11150




Sample Input

8

Sample Output

12
Note: Drinking too much cola is bad for your health, so... don't try this at home!! :-)







解法:模擬題
※由於是可借的 實際上只要一開始自己的瓶數有多兩個空瓶 那再借一瓶 喝的瓶數也就可以多一瓶





import java.util.Scanner;

public class UVA11150 {

 public static void main(String[] args) {

  Scanner sc = new Scanner(System.in);

  while (sc.hasNext()) {

   int total_bottles = sc.nextInt();

   int total_drink = total_bottles;

   while (total_bottles >= 3) {

    total_drink += total_bottles / 3;

    total_bottles = total_bottles / 3 + total_bottles % 3;

   }

   if (total_bottles == 2)
    total_drink++;

   System.out.println(total_drink);

  }

  sc.close();
 }

}