相关题目:
饮料换购https://www.acwing.com/problem/content/description/1218/
相关代码:
#include<iostream>
using namespace std;
int n;
int s;
int main(){
cin>>n;
s=n;
while(n>=3){ //不要忘记n=3时也可以换取1瓶饮料。
s+=n/3; //表示目前所喝的饮料的数量。
n=n/3+n%3; //表示目前所剩的瓶盖数量。
}
cout<<s;
return 0;
}