문제 출처 : https://www.acmicpc.net/problem/26546
언어 : Kotlin
문제 설명 :
In the String class, there exists a function called substring. Your task is to do the opposite of the substring function. Rather than returning a specified substring within the String, you will output the String with the substring taken out.
입력 :
The first line will contain a single integer n that indicates the number of data sets that follow. Each data set will be one line with a string and two integers i and j, separated by spaces. The first int, i, is the start index of the substring to be taken out, and the substring removed extends to index j-1. Thus the length of the substring removed is j-i. You may assume that 0 ≤ i ≤ j ≤ length(string).
출력 :
Output the given string, with the substring taken out specified by the given integers. The output will be n lines, with no leading or trailing white space.
제한 사항 :
- 시간 제한 : 1초
- 메모리 제한 : 1024MB
입출력 예 :
입력 | 출력 |
3 COMPUTER 1 3 SCIENCE 3 7 RULES 3 4 |
CPUTER SCI RULS |
풀이 :
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))
repeat(readLine().toInt()) {
val (str, i, j) = readLine().split(" ")
bw.appendLine(str.substring(0 until i.toInt()) + str.substring(j.toInt() .. str.lastIndex))
}
bw.flush()
bw.close()
}
'백준 > 문제' 카테고리의 다른 글
27930번: 당신은 운명을 믿나요? (0) | 2024.06.10 |
---|---|
17419번: 비트가 넘쳐흘러 (0) | 2024.06.10 |
2195번: 문자열 복사 (0) | 2024.06.07 |
30045번: ZOAC 6 (0) | 2024.06.07 |
20124번: 모르고리즘 회장님 추천 받습니다 (0) | 2024.06.07 |
포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!