Python

    [Python] 10989 ์ˆ˜ ์ •๋ ฌํ•˜๊ธฐ 3 | ๋ฉ”๋ชจ๋ฆฌ ์ดˆ๊ณผ | ์‹œ๊ฐ„ ์ดˆ๊ณผ

    ~๋ธŒ๋ก ์ฆˆ 1~ ๋งจ ๋งˆ์ง€๋ง‰์— ์ตœ์ข… ์ฝ”๋“œ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ์ œ๊ฐ€ ์–ด๋–ค ๋ฐฉ์‹์œผ๋กœ ํ—ค๋งค๋ฉฐ ํ•ด๊ฒฐํ•ด ๋‚˜๊ฐ€๋Š”์ง€ ๊ธฐ๋กํ•ฉ๋‹ˆ๋‹ค. ์ด ๊ธ€์„ ์ฝ์œผ์‹œ๋Š” ๋ถ„๋“ค๋„ ์ €์™€ ๋น„์Šทํ•œ ๋ฌธ์ œ์— ๋ถ€๋”ชํ˜”์„ ๋•Œ ์ด ๊ธ€์„ ํ†ตํ•ด ํ•ด๊ฒฐํ•˜์…จ์œผ๋ฉด ์ข‹๊ฒ ์Šต๋‹ˆ๋‹ค๐Ÿ˜‰ ํ‚ค์›Œ๋“œ #์‹œ๊ฐ„๋ณต์žก๋„ ์ตœ์†Œํ™” #๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์šฉ ์ตœ์†Œํ™” #3๋ฒˆ์˜ ๋„์ „ (ํ‹€๋ฆฐ) ์ฒซ ๋ฒˆ์งธ ์‹œ๋„๋ฅผ ๋ณด์‹œ๊ฒ ์Šต๋‹ˆ๋‹ค n = int(input()) alist = [int(input())] #๋ฆฌ์ŠคํŠธ์— ์ฒซ๋ฒˆ์งธ ๊ฐ’ ๋Œ€์ž… for i in range(n-1): #์ฒ˜์Œ ์ž…๋ ฅ๋ฐ›์€ ํšŒ์ˆ˜ ์ฐจ๊ฐํ•œ ๋งŒํผ ๋ฐ˜๋ณต a = int(input()) count = int(len(alist)) for j in range(count): #๋ฆฌ์ŠคํŠธ์— ๋“ค์–ด์žˆ๋Š” ๊ฐ’ ๊ฐœ์ˆ˜๋งŒํผ ๋ฐ˜๋ณต if a == alist[j] or a < alist[j]: #์ž…๋ ฅ๋ฐ›์€ ๊ฐ’๊ณผ ๋™์ผํ•˜..

    [Python] ๋ฐฑ์ค€ 2609 ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜์™€ ์ตœ์†Œ๊ณต๋ฐฐ์ˆ˜

    ๋ธŒ๋ก ์ฆˆ 1 ๋ฌธ์ œ (์ •๋‹ต๋งŒ์ด ์•„๋‹Œ ๊ฐœ์ธ์ ์ธ ํ’€์ด ๊ณผ์ •์„ ๊ธฐ๋กํ•ฉ๋‹ˆ๋‹ค) ์ฝ”๋“œ๋ฅผ ์„ค๋ช…ํ•˜๊ธฐ ์•ž์„œ ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜์™€ ์ตœ์†Œ๊ณต๋ฐฐ์ˆ˜๋ฅผ ์ˆ˜ํ•™์ ์œผ๋กœ ์ดํ•ดํ•ด๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. ์™œ ํ•œ ๋ฌธ์ œ์—์„œ ๋‘ ๊ฐœ๋‚˜ ํ’€์–ด์•ผ ๋ผ? ํ•  ์ˆ˜ ์žˆ์œผ๋‚˜ ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜์™€ ์ตœ์†Œ๊ณต๋ฐฐ์ˆ˜๋Š” ์ง๊ฟ์ฒ˜๋Ÿผ ๋‹ค๋‹ ์ˆ˜ ์žˆ๋Š” ์นœ๊ตฌ์ž…๋‹ˆ๋‹ค. ์œ ํด๋ฆฌ๋“œ ํ˜ธ์ œ๋ฒ•์ด๋ผ๋Š” ๋ญ”๊ฐ€ ๋Œ€๋‹จํ•ด ๋ณด์ด๋Š” ๋ฐฉ๋ฒ•์œผ๋กœ ํ’€ ์ˆ˜๋„ ์žˆ์ง€๋งŒ ์ €๋Š” ๊ฐœ๋…์„ ์ฐพ์•„๋ณด๊ณ  ์ ์šฉํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ์ ‘๊ทผํ–ˆ์Šต๋‹ˆ๋‹ค. ๊ฑฐ๋‘์ ˆ๋ฏธํ•˜๊ณ  ์ œ๊ฐ€ ์ฐธ๊ณ ํ•œ ๊ฐœ๋…์„ ๋ณด์‹œ๊ฒ ์Šต๋‹ˆ๋‹ค. ํ•ด๋‹น ๊ฐœ๋…์„ ํ†ตํ•ด ๋‘ ๊ฐœ์˜ ์ž…๋ ฅ๊ฐ’(a, b)์— ๋Œ€ํ•ด ๋‚˜๋ˆ„์–ด ๋–จ์–ด์ง€๋Š” ๊ฐ’ ์ค‘ ๊ฐ€์žฅ ํฐ ๊ฐ’(์ตœ๋Œ€๊ณต์•ฝ์ˆ˜, gcd)๊ณผ a/์ตœ๋Œ€๊ณต์•ฝ์ˆ˜ * b/์ตœ๋Œ€๊ณต์•ฝ์ˆ˜ * ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜ (์ตœ์†Œ๊ณต๋ฐฐ์ˆ˜, a*b/gcd) ๋„์ถœํ•  ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค. a, b = list(map(int, input().split())) nu..

    [Python] ๋ฐฑ์ค€ 2566 ์ตœ๋Œ“๊ฐ’ | NameError

    ๊ณผ ๊ฐ™์ด 9×9 ๊ฒฉ์žํŒ์— ์“ฐ์—ฌ์ง„ 81๊ฐœ์˜ ์ž์—ฐ์ˆ˜ ๋˜๋Š” 0์ด ์ฃผ์–ด์งˆ ๋•Œ, ์ด๋“ค ์ค‘ ์ตœ๋Œ“๊ฐ’์„ ์ฐพ๊ณ  ๊ทธ ์ตœ๋Œ“๊ฐ’์ด ๋ช‡ ํ–‰ ๋ช‡ ์—ด์— ์œ„์น˜ํ•œ ์ˆ˜์ธ์ง€ ๊ตฌํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. ์˜ˆ๋ฅผ ๋“ค์–ด, ๋‹ค์Œ๊ณผ ๊ฐ™์ด 81๊ฐœ์˜ ์ˆ˜๊ฐ€ ์ฃผ์–ด์ง€๋ฉด ์ด๋“ค ์ค‘ ์ตœ๋Œ“๊ฐ’์€ 90์ด๊ณ , ์ด ๊ฐ’์€ 5ํ–‰ 7์—ด์— ์œ„์น˜ํ•œ๋‹ค. ์ฒ˜์Œ ์ œ์ถœํ•œ ์ฝ”๋“œ๋ฅผ ๋จผ์ € ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. *ํ‹€๋ฆฐ ์ฝ”๋“œ ์ž…๋‹ˆ๋‹ค maxN = 0 row = 0 col = 0 for i in range(9): nlist = list(map(int, input().split())) for j in range(9): if nlist[j] > maxN: maxN = nlist[j] row = i+1 col = j+1 print(maxN) print(row, end=" ") print(col) ๋ฌด์—‡์ด ์ž˜๋ชป ๋˜์—ˆ..

    [Python] ๋ฐฑ์ค€ 10807 ๊ฐœ์ˆ˜์„ธ๊ธฐ

    input() nlist = list(map(int, input().split())) v = int(input()) count = 0 for n in nlist: if v == n: count += 1 print(count) ๋”ฐ๋กœ ์„ค๋ช…์€ ํ•˜์ง€์•Š๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค ๊ถ๊ธˆํ•œ ์ ์ด ์žˆ๋‹ค๋ฉด ๋Œ“๊ธ€ ๋‹ฌ์•„์ฃผ์„ธ์š”!