汽水瓶

#include<iostream>
using namespace std;

int judge(int n);
int main(){
    int n;
    while(cin>>n){
        if(n == 0) break;
        int result = judge(n);
        cout<<result<<endl;
    }
}

int judge(int n){
    int rest = n;
    int sum = 0;
    while(rest > 1){
        if(rest == 2){
            sum = sum + 1;
            return sum;
        }
        sum = sum + rest/3;
        rest = rest/3 + rest%3;

    }
    return sum;
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章