#include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) int main() { // Input int X; cin >> X; // Simulation int move[7] = {2, 2, -1, -1, 2, -1, -1}; int pos = 0; int ans = 0; rep(i, 100) { rep(j, 7) { pos += move[j]; ans += abs(move[j]); if (pos == X) goto OUTPUT; } } OUTPUT: // Output cout << ans << endl; }