1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include <iostream> int main() { int n; std::cin >> n; int result = n; while (n >= 3) { int exchange = n / 3; int rest = n % 3; result += exchange; n = exchange + rest; } std::cout << result; return 0; }