题解 | #汽水瓶#
汽水瓶
https://www.nowcoder.com/practice/fe298c55694f4ed39e256170ff2c205f
#include<stdio.h>
int main(void)
{
int n;
int rest;
int drink=0;
while(scanf("%d",&n)!=EOF)
{
if(n==0)
{
// printf("\n");
}
else if(n==1)
{
drink=0;
}
else if(n>=2)
{
while(n>2)
{
drink+=n/3;
n=(n/3)+(n%3);
}
if(n==2)
{
drink++;
}
printf("%d\n",drink);
drink=0;
}
}
return 0;
}
int main(void)
{
int n;
int rest;
int drink=0;
while(scanf("%d",&n)!=EOF)
{
if(n==0)
{
// printf("\n");
}
else if(n==1)
{
drink=0;
}
else if(n>=2)
{
while(n>2)
{
drink+=n/3;
n=(n/3)+(n%3);
}
if(n==2)
{
drink++;
}
printf("%d\n",drink);
drink=0;
}
}
return 0;
}