This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Author : Md.Mehadi Hasan Menon. | |
* Problem : 11877 - The Coco-Cola Store. | |
* Status : Accepted. | |
* Date : 09.11.2014. | |
**/ | |
#include <stdio.h> | |
int main() | |
{ | |
int n, sum; | |
while(scanf("%d", &n) == 1) | |
{ | |
if(n == 0) break; | |
sum = 0; | |
while(n >= 3) | |
{ | |
sum += n / 3; | |
n = (n % 3) + (n / 3); | |
} | |
if(n == 2) | |
printf("%d\n", sum + 1); | |
else | |
printf("%d\n", sum); | |
} | |
return 0; | |
} |
Comments
Post a Comment