๐ŸŒฑ → ๐ŸŒณ

[๋ฐฑ์ค€] 1152๋ฒˆ: ๋‹จ์–ด์˜ ๊ฐœ์ˆ˜ python ๋ณธ๋ฌธ

Algorithms

[๋ฐฑ์ค€] 1152๋ฒˆ: ๋‹จ์–ด์˜ ๊ฐœ์ˆ˜ python

BAY 2022. 7. 15. 17:42
728x90

https://www.acmicpc.net/problem/1152

 

1152๋ฒˆ: ๋‹จ์–ด์˜ ๊ฐœ์ˆ˜

์ฒซ ์ค„์— ์˜์–ด ๋Œ€์†Œ๋ฌธ์ž์™€ ๊ณต๋ฐฑ์œผ๋กœ ์ด๋ฃจ์–ด์ง„ ๋ฌธ์ž์—ด์ด ์ฃผ์–ด์ง„๋‹ค. ์ด ๋ฌธ์ž์—ด์˜ ๊ธธ์ด๋Š” 1,000,000์„ ๋„˜์ง€ ์•Š๋Š”๋‹ค. ๋‹จ์–ด๋Š” ๊ณต๋ฐฑ ํ•œ ๊ฐœ๋กœ ๊ตฌ๋ถ„๋˜๋ฉฐ, ๊ณต๋ฐฑ์ด ์—ฐ์†ํ•ด์„œ ๋‚˜์˜ค๋Š” ๊ฒฝ์šฐ๋Š” ์—†๋‹ค. ๋˜ํ•œ ๋ฌธ์ž์—ด

www.acmicpc.net

์ •๋‹ต ์ฝ”๋“œ:

word = input().split()
print(len(word))

 

์ฒ˜์Œ ์ž‘์„ฑํ•œ ์ฝ”๋“œ:

a = input()
cnt = 1
for i in a:
  if i==" ":
    cnt= cnt + 1
print(cnt)

 

728x90