fragment-header
fragment-markdown
홈
로그인
로그아웃
내 블로그
설정
로그인
백준 6260 (C++) Encrypted SMS
최초 업로드: 2025-09-03 03:50:22
최근 수정 시간: 2025-09-03 03:50:43
게시자: rlatjwls3333
카테고리: 백준
조회수: 9
# [Bronze I] Encrypted SMS [문제 링크](https://www.acmicpc.net/problem/6260) ## 문제 설명 <p>This year, ACM scientific committee members use emails to discuss about the problems and edit the selected ones. They know that email is not a secure way of communication, especially on such an important topic. So they transfer password-protected compressed file among themselves. In order to send the passwords, they use SMS. To increase the security level, the encrypted passwords are sent by SMS. To do this, a multi-tap SMS typing method is used.</p> <p>Multi-tap is currently the most common text input method for mobile phones. With this approach, the user presses each key one or more times to obtain the wanted characters. For example, the key 2 is pressed once to get character A, twice for B, and three times for C.</p> <p>The encryption algorithm that is used is quite simple: to encrypt the i th character of the password, the key used to obtain that character is tapped i more times. For if the 4th character of password is U, the key 8 is tapped 6 times, getting the character V. Note that to make the problem simple, we have assumed that the keypad does not generate digits.</p> <p>The scientific committee needs a program to decrypt the received passwords. They are too busy to write this program and have asked you to help! Write a program to get a correct encrypted text and print the original password.</p> <p style="text-align: center;"><img alt="" src="https://onlinejudgeimages.s3-ap-northeast-1.amazonaws.com/problem/6260/1.png" style="height:215px; width:229px"></p> <p style="text-align: center;">The standard 12 key telephone keypad</p> ## 입력 <p>The input consists of multiple test cases. Each test case contains a non-empty string of length at most 100, consisting of small or capital English letters. The last line of the input contains a single #.</p> ## 출력 <p>For each test case, write the decrypted password in a separate line. Note that passwords are case-sensitive.</p> ## 풀이 각 문자마다 이동해야 하는 문자를 마킹하고 직접 이동시켜서 풀었습니다. ``` c++ #include<bits/stdc++.h> using namespace std; char prv[] = {'C', 'A', 'B', 'F', 'D', 'E', 'I', 'G', 'H', 'L', 'J', 'K', 'O', 'M', 'N', 'S', 'P', 'Q', 'R', 'V', 'T', 'U', 'Z', 'W', 'X', 'Y'}; int main() { ios::sync_with_stdio(0); cin.tie(0); while(true) { string s; cin >> s; if(s[0]=='#') break; for(int i=0;i<s.length();i++) { int cnt=i+1; while(cnt--) { if(s[i]>='a') s[i] = prv[s[i]-'a']+32; else s[i] = prv[s[i]-'A']; } } cout << s << '\n'; } } ```