题目描述
乐羊羊饮料厂正在举办一次促销优惠活动。乐羊羊 C 型饮料,凭 3 3 3 个瓶盖可以再换一瓶 C 型饮料,并且可以一直循环下去(但不允许暂借或赊账)。
请你计算一下,如果小明不浪费瓶盖,尽量地参加活动,那么,对于他初始买入的 n n n 瓶饮料,最后他一共能喝到多少瓶饮料。
输入格式
一个整数 n n n,表示开始购买的饮料数量。( 0 < n < 10000 0<n<10000 0<n<10000)
输出格式
一个整数,表示实际得到的饮料数。
样例 #1
样例输入 #1
100
样例输出 #1
149
样例 #2
样例输入 #2
101
样例输出 #2
151
提示
2015 年蓝桥杯省赛 A 组 H 题。
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
#define int long long
#define endl '\n'
int n,ans;
void solve(){
cin>>n;
ans=n;
while(n>=3){
ans+=n/3;
n=n%3+n/3;
}
cout<<ans;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t=1;
// cin>>t;
while(t--) solve();
return 0;
}