1216. 饮料换购

https://www.acwing.com/problem/content/1218/

大水题
233

简单数理分析即可知

由n瓶饮料,可以产生n个瓶盖 , 又可以用n个瓶盖换取n/3(下取整)瓶饮料,如此反复换取,直至瓶盖不足3个为止

#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
int n;
int res;
int main()
{
    cin >> n;
    res=n;
    while(n>=3)
    {
        res+=n/3;
        n=n/3+n%3;
    }
    cout << res << endl;
    return 0;
}

 

posted @ 2022-09-21 22:47  风乐  阅读(19)  评论(0)    收藏  举报