[蓝桥杯][2015年第六届真题]饮料换购

水题。

int n;

int main()
{
    cin>>n;

    int res=n;
    int carry=0;
    while(n)
    {
        n+=carry;
        carry=n%3;
        n/=3;
        res+=n;
    }
    cout<<res<<endl;
    //system("pause");
    return 0;
}
posted @ 2021-03-23 21:15  Dazzling!  阅读(23)  评论(0编辑  收藏  举报