// No.405 ローマ数字の腕時計 // https://yukicoder.me/problems/no/405 // #include #include #include #include using namespace std; string solve(string &S1, int T); int main() { string S1; int T; cin >> S1 >> T; string ans = solve(S1, T); cout << ans << endl; } string solve(string &S1, int T) { vector clock {"I", "II", "III", "IIII", "V", "VI", "VI", "VIII", "IX", "X", "XI", "XII"}; while (clock[0] != S1) { rotate(clock.begin(), clock.begin()+1, clock.end()); } while (T < 0) // マイナス方向にはrotate()できないらしい T += clock.size(); rotate(clock.begin(), clock.begin()+T, clock.end()); return clock[0]; }