문제 출처 : https://www.acmicpc.net/problem/8387
언어 : Kotlin
문제 설명 :
In the recent years children in Byteland have been hardly reading any books. This has a negative influence on the knowledge of orthography among Byteland residents. Teachers at schools do their best to change this situation. They organize many different tests and contests. The objective is to increase the knowledge of orthography among pupils. This, however, does not improve the situation much. Many children own dyslexia certificate, which allows them not to care about the orthographical mistakes that they make. Ministry of Education decided to counteract this situation. It has been decided that every owner of a dyslexia certificate has to prove that she or he is indeed dyslexic. There are so many children affected by dyslexia in Byteland that it is required to automate the process of validation. All children will have to rewrite a special set of texts on a computer. The number of correctly rewritten letters will make it possible to decide, whether the pupil is a dyslexic or not. Ministry of Education would like you to prepare a validating program for this test.
Write a program which:
- reads two texts from the standard input - the original one and the version rewritten by a pupil,
- determines the number of letters that were rewritten correctly,
- writes the result to the standard output.
입력 :
In the first line there is one integer n (1 ≤ n ≤ 100 000), representing the length of the original text (it is also the length of the second text). The second line contains the original text. It consists of n small and/or capital letters of the English alphabet. The third line contains the text rewritten by a pupil. It also consists of n small and/or capital letters of the English alphabet.
출력 :
The first and only line of output should contain one non-negative integer - the number of letters that were rewritten correctly.
제한 사항 :
- 시간 제한 : 1초
- 메모리 제한 : 128MB
입출력 예 :
입력 | 출력 |
28 JASIONIEJESTDYSORTOGRAFIKIEM JASIOmbsefSTDYqwerOGsxFqasEM |
14 |
풀이 :
import java.io.BufferedWriter
import java.io.OutputStreamWriter
fun main() = with(System.`in`.bufferedReader()) {
val bw = BufferedWriter(OutputStreamWriter(System.out))
val n = readLine().toInt()
val original = readLine()
val reWritten = readLine()
var cnt = 0
for (i in original.indices) {
if (reWritten[i] == original[i]) cnt++
}
bw.write("$cnt")
bw.flush()
bw.close()
}
'백준 > 문제' 카테고리의 다른 글
15464번: The Bovine Shuffle (0) | 2024.08.30 |
---|---|
1148번: 단어 만들기 (0) | 2024.08.29 |
9612번: Maximum Word Frequency (0) | 2024.08.28 |
1622번: 공통 순열 (0) | 2024.08.28 |
22950번: 이진수 나눗셈 (0) | 2024.08.27 |
포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!