UVA – 11877 – The Coco-Cola Store


#include <iostream>
#include <cstdio>
#include <cstring>
#include <string.h>
#include <string>
#include <cmath>
using namespace std;
int n, total;

int main() {
	while (scanf("%d", &n) && n && !(total=0)) {
		while (n >= 3)
			total += n / 3, n = (n / 3) + (n % 3);
		printf("%d\n", total + (n == 2));
	}
	return 0;
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: