題目:
https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=23&page=show_problem&problem=2091
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| #include <iostream>
using namespace std;
int main(){ int n; while(cin >> n){ int total = n; int empty = n; while(empty >= 3){ total += empty / 3; empty = empty/3 + (empty%3); } if(empty == 2) ++ total;
cout << total << '\n'; } return 0; }
|