#include #include int main(){ char S1[5]; int tmp[5], T, i = 0, wp = 0, wp2 = 0, S_time, mod; char CLK[12][5] = {"I", "II", "III", "IIII", "V", "VI", "VII", "VIII", "IX", "X", "XI", "XII"}; while(1){ scanf("%c", &tmp[wp++]); if((tmp[wp - 1] == 'I') | (tmp[wp - 1] == 'V') | (tmp[wp - 1] == 'X')){ S1[wp2++] = (char)tmp[wp - 1]; //printf("S1 %c\n", S1[wp2 - 1]); }else{ S1[wp2] = '\0'; scanf("%d", &tmp[--wp]); wp++; T = tmp[wp - 1]; //printf("T %d\n", T); break; } } //printf("S1: %s CLK[11]: %s\n", S1, CLK[11]); for(i = 0; i < 12; i++){ if(strcmp(CLK[i], S1) == 0){ S_time = i + 1; //printf("S_time %d\n", S_time); } } mod = T%12; //printf("mod: %d\n", mod); if(S_time + mod >= 0){ printf("%s\n", CLK[S_time + mod - 1]); }else{ printf("%s\n", CLK[S_time + mod + 12 - 1]); } return 0; }