dev/algorithm
BOJ / 1543๋ฒ / ๋ฌธ์ ๊ฒ์ [Go][Python3]
crscnt
2021. 2. 11. 21:00
๐ฉ๐ป๐ป ๋ฌธ์
1543๋ฒ: ๋ฌธ์ ๊ฒ์
์ธ์ค์ด๋ ์์ด๋ก๋ง ์ด๋ฃจ์ด์ง ์ด๋ค ๋ฌธ์๋ฅผ ๊ฒ์ํ๋ ํจ์๋ฅผ ๋ง๋ค๋ ค๊ณ ํ๋ค. ์ด ํจ์๋ ์ด๋ค ๋จ์ด๊ฐ ์ด ๋ช ๋ฒ ๋ฑ์ฅํ๋์ง ์ธ๋ ค๊ณ ํ๋ค. ๊ทธ๋ฌ๋, ์ธ์ค์ด์ ํจ์๋ ์ค๋ณต๋์ด ์ธ๋ ๊ฒ์ ๋นผ๊ณ ์ธ์ผ ํ
www.acmicpc.net
โ๐ป ํ์ด
๐จ Go
// https://www.acmicpc.net/problem/1543
package main
import (
"bufio"
"fmt"
"os"
"strings"
)
func main() {
reader := bufio.NewReader(os.Stdin)
writer := bufio.NewWriter(os.Stdout)
defer writer.Flush()
var document, word string
document, _ = reader.ReadString('\n')
document = strings.ReplaceAll(document, "\n", "")
word, _ = reader.ReadString('\n')
word = strings.ReplaceAll(word, "\n", "")
fmt.Println(strings.Count(document, word))
}
๐จ Python3
# https://www.acmicpc.net/problem/1543
import sys
if __name__ == "__main__":
document = sys.stdin.readline().rstrip()
word = sys.stdin.readline().rstrip()
print(document.count(word))
728x90