nyoj-662-汽水瓶

 1 #include<stdio.h>
 2 #include<string.h>
 3 #include<algorithm>
 4 #include<math.h>
 5 using namespace std;
 6 int main()
 7 {
 8     int n;
 9     while(scanf("%d",&n),n)
10     {
11         int p=n,sum=0,temp;
12         while(p>=3)
13         {
14             temp=p/3;
15             p%=3;
16             sum+=temp;
17             p+=temp;
18         }
19         if(p==2)
20         sum++;
21         printf("%d\n",sum);
22     }
23     return 0;
24 }

 

posted @ 2013-07-13 16:18  nylg-haozi  阅读(106)  评论(0编辑  收藏  举报