답안 #17503

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
17503 2015-12-22T02:58:56 Z kdh9949 고장난 휴대전화기 (COCI14_mobitel) C++
50 / 50
0 ms 1084 KB
#include <cstdio>

int key[10];
char str[101];
int whatkey[26] = {2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 9};
int num[26] = {1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 1, 2, 3, 4};

int main(){
    int cur;
    for(int i = 1; i <= 9; i++){
        scanf("%d", &cur);
        key[cur] = i;
    }
    scanf("%s", str);
    int last = -1;
    for(int i = 0; str[i]; i++){
        cur = str[i] - 'a';
        if(last == whatkey[cur]) putchar('#');
        for(int i = 0; i < num[cur]; i++) printf("%d", key[whatkey[cur]]);
        last = whatkey[cur];
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1084 KB Output is correct
2 Correct 0 ms 1084 KB Output is correct
3 Correct 0 ms 1084 KB Output is correct
4 Correct 0 ms 1084 KB Output is correct
5 Correct 0 ms 1084 KB Output is correct
6 Correct 0 ms 1084 KB Output is correct
7 Correct 0 ms 1084 KB Output is correct
8 Correct 0 ms 1084 KB Output is correct
9 Correct 0 ms 1084 KB Output is correct
10 Correct 0 ms 1084 KB Output is correct