문제 출처 : https://www.acmicpc.net/problem/26594
언어 : Kotlin
문제 설명 :
Now that Snapchat and Slingshot are soooo 2018, the teenagers of the world have all switched to the new hot app called BAPC (Bidirectional and Private Communication). This app has some stricter social rules than previous iterations. For example, if someone says goodbye using Later!, the other person is expected to reply with Alligator!. You can not keep track of all these social conventions and decide to automate any necessary responses, starting with the most important one: the greetings. When your conversational partner opens with he...ey, you have to respond with hee...eey as well, but using twice as many e’s!
Given a string of the form he...ey of length at most 1000, print the greeting you will respond with, containing twice as many e’s.
입력 :
The input consists of one line containing a single string s as specified, of length at least 3 and at most 1000.
출력 :
Output the required response.
제한 사항 :
- 시간 제한 : 1초 (추가 시간 없음)
- 메모리 제한 : 512MB
입출력 예 :
입력 | 출력 |
hey | heey |
heeeeey | heeeeeeeeeey |
풀이 :
import java.io.BufferedReader
import java.io.BufferedWriter
import java.io.InputStreamReader
import java.io.OutputStreamWriter
fun main() = with(BufferedReader(InputStreamReader(System.`in`))) {
val bw = BufferedWriter(OutputStreamWriter(System.out))
readLine().also {
val cnt = it.count { it == 'e' }
bw.write("h${"e".repeat(cnt * 2)}y")
}
bw.flush()
bw.close()
}
'백준 > 문제' 카테고리의 다른 글
27880번: Gahui and Soongsil University station (0) | 2024.06.27 |
---|---|
17828번: 문자열 화폐 (0) | 2024.06.27 |
26594번: ZOAC 5 (0) | 2024.06.26 |
10256번: 돌연변이 (0) | 2024.06.26 |
9519번: 졸려 (0) | 2024.06.26 |
포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!