1.

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS11
* Problem: 11877 - The Coco-Cola Store
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=226&page=show_problem&problem=2999
*
* @author Christian Posselt
* @author Christian Mitterreiter
* @version 1.0, 23.03.2011
*
* Status: Accepted
* Time: 0.104
*/

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{

public static void main(String[] args) throws IOException
{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

do
{
int bottles;
// read the numbers of empty bottles
bottles = Integer.parseInt(reader.readLine().toLowerCase());

// if it is 0, do not proceed
if(bottles == 0)
break;

System.out.printf("%d%n",drink(bottles));
}
while(reader.ready());

}

/**
* drink
*
* determines the amount of coca cola you can drink
*
* @param bottles: int with the amount of empty bottles
* @return amount of bottles you can drink
*/
public static int drink(int bottles)
{
//if you have 2 empty bottles, you can borrow an empty bottle from the shop.
//Now you can get another full bottle, which you can return after you drank it.
if(bottles == 2)
return 1;

int result = bottles / 3;

//recursive determination of bottles you can still get after getting the new bottles
if(result + bottles % 3 >= 2)
result += drink(result + bottles % 3);

return result;
}

}



-------------------------------

1.
/*
* ACM Contest training
* Problem: 11877 - The Coco-Cola Store
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=226&page=show_problem&problem=2999
*
* @author Christoph Goettschkes
* @version 1.0, 11/08/2010
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.108
*/

import java.io.*;

class Main
{
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

int n = Integer.parseInt(reader.readLine().trim());

while (n > 0) {
int d = 0;

int full = 0;
int empty = n;
int counter = 7;
while (empty > 0 && counter > 0) {
full = empty / 3;
empty %= 3;
d += full;
empty += full;
full = 0;
counter--;
if (empty == 2)
empty++;
}
System.out.println(d);

n = Integer.parseInt(reader.readLine().trim());
}
}
}