ํ‹ฐ์Šคํ† ๋ฆฌ ๋ทฐ

๐Ÿ‘ฉ๐Ÿป‍๐Ÿ’ป ๋ฌธ์ œ

 

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
๋Œ“๊ธ€