๋ถ„๋ฅ˜ ์ „์ฒด๋ณด๊ธฐ

    [Python] ์ž…๋ ฅ ์ฒ˜๋ฆฌ ์ •๋ฆฌ | input | readline | ๊ณ„์† ์ž…๋ ฅ ๋ฐ›๊ธฐ | ๋ฆฌ์ŠคํŠธ๋กœ ์ž…๋ ฅ๋ฐ›๊ธฐ

    Python์„ ์ฒ˜์Œ์— ์‚ฌ์šฉํ•  ๋•Œ ํ˜น์€ ๋ฐฑ์ค€์„ ํ’€๊ธฐ ์œ„ํ•ด์„œ ์ž…๋ ฅ๊ฐ’์„ ๋ฐ›์•„์•ผ ํ•  ๋•Œ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค ์˜ค๋Š˜์€ ์ž…๋ ฅ์„ ๋ฐ›๊ธฐ ์œ„ํ•œ ์—ฌ๋Ÿฌ๊ฐ€์ง€ ๋ฐฉ๋ฒ•๊ณผ ์ดํ›„ ์ฒ˜๋ฆฌ ๋ฐฉ๋ฒ•๋“ค์„ ์ •๋ฆฌํ•ด๋ณด๋„๋กํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค ~๋ชฉ์ฐจ~ 1. input() 2. readline() 3. ๊ณ„์† ์ž…๋ ฅ ๋ฐ›๊ธฐ 3-1) for + stdin 3-2) while + try + readline 4. ์—ฌ๋Ÿฌ๊ฐ’์ด ํ•œ ์ค„์— ์žˆ์„ ๋•Œ : ๋ฆฌ์ŠคํŠธ๋กœ ์ž…๋ ฅ๋ฐ›๊ธฐ 1. input() Python์—์„œ ์ž…๋ ฅ๊ฐ’์„ ๋ฐ›์„ ์ˆ˜ ์žˆ๋Š” ๊ฐ€์žฅ ๊ฐ„๋‹จํ•œ ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค. ๋”ฐ๋กœ ์ถ”๊ฐ€ํ•  ๋ชจ๋“ˆ ์—†์ด ๋ฐ”๋กœ ์ž…๋ ฅ์„ ๋ฐ›์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค! ๊ฐ„๋‹จํ•œ ์ฝ”๋“œ๋ฅผ ๊ฐ™์ด ๋ด…์‹œ๋‹ค. number = input() print("์ˆซ์ž %s๋ฅผ ์ž…๋ ฅํ•˜์…จ์Šต๋‹ˆ๋‹ค!" % number) #24 #์ˆซ์ž 24๋ฅผ ์ž…๋ ฅํ•˜์…จ์Šต๋‹ˆ๋‹ค! ์—ฌ๊ธฐ์„œ ์ฃผ์˜ ํ•  ์ ์€ input์œผ..

    [MySQL] ์ค‘๋ณต๊ฐ’ ์ œ์™ธ(GROUP BY, DISTINCT) | NULL ๊ฐ’ ์ œ์™ธ(IS id NOT NULL)

    ์†Œํ”„ํŠธ์›จ์–ด ๋งˆ์—์ŠคํŠธ๋กœ ์ฝ”๋”ฉํ…Œ์ŠคํŠธ์— ๋Œ€๋น„ํ•˜๊ธฐ ์œ„ํ•ด์„œ Programmers SQL ๊ณ ๋“์  Kit๋ฅผ ๊ณต๋ถ€ํ•˜๊ฒŒ ๋์Šต๋‹ˆ๋‹ค. ์ƒˆ๋กœ ์•Œ๊ฒŒ ๋œ, ๊นŒ๋จน์—ˆ๋˜ ๋ฌธ๋ฒ•์„ ์ •๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด ๋ฌธ์ œ ๊ธฐ๋ฐ˜์œผ๋กœ ์ •๋ฆฌํ•˜๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค~ ๊ทธ๋Ÿผ ์„œ๋ก ์€ ์ด์ฏค๊นŒ์ง€ ํ•˜๊ณ  ์ œ๋ชฉ์„ ๋ณด๊ณ  ๋“ค์–ด์˜ค์‹  ๋ถ„๊ป˜ ๋„์›€์ด ๋  ๋ฌธ์ œ๋ฅผ ๊ณต๊ฐœํ•ฉ๋‹ˆ๋‹ค! '์ค‘๋ณต ์ œ๊ฑฐํ•˜๊ธฐ' ํ•ด๋‹น ๊ธ€์—์„œ๋Š” ๋ฌธ์ œํ’€์ด ๊ณต๊ฐ„์ด ์•„๋‹ˆ๊ณ  ๊ฐœ๋… ์ •๋ฆฌ๋ฅผ ์ง„ํ–‰ํ•  ๊ฒƒ์ž…๋‹ˆ๋‹ค ๋‹ค์Œ ๋‘ ๊ฐœ ๋งํฌ๋ฅผ ํ†ตํ•ด ๋ฌธ์ œ๋ฅผ ํ’€์–ด๋ณด์‹œ๊ณ  ํ’€์ด๊นŒ์ง€ ๋ณด์‹œ๋Š” ๊ฒƒ์„ ์ถ”์ฒœ๋“œ๋ฆฝ๋‹ˆ๋‹ค! [๋ฌธ์ œ ํ’€์–ด๋ณด๊ธฐ] https://school.programmers.co.kr/learn/courses/30/lessons/59408 ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ..

    [Python] ๋ฐฑ์ค€ 2563 ์ƒ‰์ข…์ด

    ์†Œ๋งˆ ์ฝ”ํ…Œ๋ฅผ ์ฒ˜์Œ ์ค€๋น„ํ•˜๋˜ ๋•Œ ํ’€์ดํ–ˆ๋˜ ๊ฒƒ์ธ๋ฐ ์ •๋ง ์–ด๋–ป๊ฒŒ ํ’€๊ณ ์‹ถ์—ˆ๋˜๊ฑด์ง€ ๊ฐ์ด ์•ˆ ์žกํžŒ๋‹ค..ใ…‹ใ…‹ใ…‹ใ…‹ใ…‹ ์ฒ˜์Œ ์‹œ๋„ํ•œ ๋ฐฉ์‹์˜ ํ’€์ด๋Š” ๋‹ค์Œ ๊ฐ™๋‹ค. [์‹คํŒจํ•œ ์ฝ”๋“œ] paper = int(input()) papers = [[0]*paper for i in range(paper)] result = 0 x = 0 y = 0 for i in range(paper): papers[i] = list(map(int, input().split())) for i in range(paper): for j in range(i+1, paper): if papers[i][0] < papers[j][0] < papers[i][0] + 10: x = papers[i][0] + 10 - papers[j][0] if papers[i][1] ..

    [Python] 1783 ๋ณ‘๋“  ๋‚˜์ดํŠธ | ๊ทธ๋ฆฌ๋”” ์•Œ๊ณ ๋ฆฌ์ฆ˜

    ~์‹ค๋ฒ„ 3~ https://www.acmicpc.net/problem/1783 1783๋ฒˆ: ๋ณ‘๋“  ๋‚˜์ดํŠธ ์ฒซ์งธ ์ค„์— ์ฒด์ŠคํŒ์˜ ์„ธ๋กœ ๊ธธ์ด N์™€ ๊ฐ€๋กœ ๊ธธ์ด M์ด ์ฃผ์–ด์ง„๋‹ค. N๊ณผ M์€ 2,000,000,000๋ณด๋‹ค ์ž‘๊ฑฐ๋‚˜ ๊ฐ™์€ ์ž์—ฐ์ˆ˜์ด๋‹ค. www.acmicpc.net [๋ฌธ์ œ ํ•ด๊ฒฐ ํฌ์ธํŠธ] 1. ์ œํ•œ ์‚ฌํ•ญ์„ ๋‹จ๊ณ„์ ์œผ๋กœ ๋ถ„๋ฆฌํ•˜๊ธฐ 2. n์˜ ์ œํ•œ ์‚ฌํ•ญ ์ดํ•ดํ•˜๊ธฐ 3. m์˜ ์ œํ•œ ์‚ฌํ•ญ ์ดํ•ดํ•˜๊ธฐ 1. ์ œํ•œ ์‚ฌํ•ญ์„ ๋‹จ๊ณ„์ ์œผ๋กœ ๋ถ„๋ฆฌํ•˜๊ธฐ ์ฒ˜์Œ์— ๋ฌธ์ œ๋ฅผ ์ฝ์œผ๋ฉด '... ๋ญ ์–ด์ฉŒ๋ผ๋Š” ๊ฑฐ์•ผ' ํ˜น์€ '์ด๊ฑธ ์–ด๋–ป๊ฒŒ ํ’€๋ผ๋Š” ๊ฑฐ์•ผ'๋ผ๋Š” ์ƒ๊ฐ์„ ํ• ์ง€๋„ ๋ชจ๋ฅธ๋‹ค ๋‚ด๊ฐ€ ๊ทธ๋žฌ๋‹ค ๋‹ค์‹œ ํ•œ๋ฒˆ ๋ฌธ์ œ๋ฅผ ์ฐฌ์ฐฌํžˆ ์‚ดํŽด๋ณด๊ณ  ์ œํ•œ ์‚ฌํ•ญ์„ ๊ผผ๊ผผํžˆ ์‚ดํŽด๋ณด๋ฉฐ์นจ์ฐฉํ•˜๊ฒŒ ์ƒ๊ฐํ•ด ๋ณผ ํ•„์š”๊ฐ€ ์žˆ๋‹ค. ๋ชจ๋“  ์‹œ์ž‘ ์œ„์น˜๋Š” (0, 0)์ด๋ผ๊ณ  ๊ฐ€์ •ํ•œ๋‹ค. ์ž…๋ ฅ์œผ๋กœ ์ฃผ์–ด์ง€๋Š” n๊ณผ m์˜ ํฌ๊ธฐ..

    [Python | week1-4] ๊ทธ๋ฆฌ๋”” ์•Œ๊ณ ๋ฆฌ์ฆ˜(Greedy Algorithm) |

    week 1-4 1-1๋ถ€ํ„ฐ ํ˜„์žฌ ๊ธ€(1-4)๊นŒ์ง€ ๋งค๋ฒˆ ์ž‘์„ฑํ•œ ๊ธ€์€ 4์ฃผ์ฐจ, ์ฆ‰ week 4๊นŒ์ง€ ์ž‘์„ฑ ๋  ์˜ˆ์ •์ž…๋‹ˆ๋‹ค. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค School ์—์„œ ์ง„ํ–‰ํ•˜๋Š” ์ฝ”ํ…Œ ์ค€๋น„ ๊ฐ•์˜๋กœ ๋ณธ ๊ณผ์ •์„ ๋”์šฑ ๊นŠ์ด ์ดํ•ดํ•˜๊ธฐ ์œ„ํ•ด์„œ ์Šค์Šค๋กœ ์ž‘์„ฑํ•˜๋Š” ์‹œ๋ฆฌ์ฆˆ์ž…๋‹ˆ๋‹ค week1-2 ์—์„œ ํ•™์Šตํ•œ ๊ทธ๋ฆฌ๋”” ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด ๋˜ ๋‹ค์‹œ ๋“ฑ์žฅํ–ˆ์Šต๋‹ˆ๋‹ค! 2023.01.13 - [๐Ÿ“‚Language/Python] - [Python | week1-2] Greedy ์•Œ๊ณ ๋ฆฌ์ฆ˜ | ์ด๊ฒƒ์ด ์ฝ”๋”ฉํ…Œ์ŠคํŠธ๋‹ค [Python | week1-2] Greedy ์•Œ๊ณ ๋ฆฌ์ฆ˜ | ์ด๊ฒƒ์ด ์ฝ”๋”ฉํ…Œ์ŠคํŠธ๋‹ค week1-2 [์˜ค๋Š˜์˜ ํ•™์Šต] 1. Greedy ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๊ฐœ๋… 2. '์ฒด์œก๋ณต' ๋ฌธ์ œ ํ’€์ด 3. ๊ทธ๋ฆฌ๋”” ์•Œ๊ณ ๋ฆฌ์ฆ˜ ์ถ”์ฒœ ํ•™์Šต 1. Greedy Algorithm ๊ฐœ๋… ์ด๋ฆ„๊ณผ ๊ฐ™์ด ํƒ์š•์Šค๋Ÿฌ์šด ..

    [Python | week1-3] ์ •๋ ฌ | Sort ํ•จ์ˆ˜ | divmod ํ•จ์ˆ˜ | ์žฌ๊ท€ ์•Œ๊ณ ๋ฆฌ์ฆ˜

    Week1-3 [์˜ค๋Š˜์˜ ํ•™์Šต] 1. ์ •๋ ฌ ์•Œ๊ณ ๋ฆฌ์ฆ˜(sort, sorted ํ•จ์ˆ˜) 2. divmod ํ•จ์ˆ˜ 3. ์žฌ๊ท€ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ~ํ˜ผ์žฃ๋ง~ ๋ฐฑ์ค€์ด ์ต์ˆ™ํ•ด์„œ์ธ์ง€ ์•„๋‹ˆ๋ฉด ๋ฌด์–ธ๊ฐ€ ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ์‚ฌ์šฉํ•ด์•ผ ๋œ๋‹ค๋Š” ๊ฐ•๋ฐ• ๊ด€๋… ๋•Œ๋ฌธ์ธ์ง€ ์š”์ฆ˜ ๋ฌธ์ œ๊ฐ€ ์ž˜ ํ’€๋ฆฌ์ง€ ์•Š๋Š”๋‹ค ๋ฌธ์ œ ํ•ด๊ฒฐ ์ฝ”๋“œ๋ฅผ ๋ณด๋ฉด "์™€ ์ด๊ฑฐ๋‹ค" ์‹ถ์€๋ฐ ๋ง‰์ƒ ์Šค์Šค๋กœ ํ•˜๋ ค๊ณ  ํ•˜๋ฉด ๋ง‰๋ง‰ํ•˜๊ณ  ๋‹ต๋‹ตํ•˜๋‹ค ์ด์ „์—๋„ ์ด๋Ÿฐ ๊ฒฝํ—˜์ด ์žˆ๋Š”๋ฐ, ๊พธ์ค€ํžˆ ๋ฌธ์ œ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•์„ ๊ณต๋ถ€ํ•˜๋‹ค ๋ณด๋ฉด ํ•ด๊ฒฐ ํ๋ฆ„์„ ์Šค์Šค๋กœ ๋– ์˜ฌ๋ฆด ์ˆ˜ ์žˆ์œผ๋ฆฌ๋ผ ๋ฏฟ์–ด ์˜์‹ฌ์น˜ ์•Š๋Š”๋‹ค 1. ์ •๋ ฌ ์•Œ๊ณ ๋ฆฌ์ฆ˜(sort, sorted ํ•จ์ˆ˜) ์ •๋ ฌ์€ ์ฝ”๋”ฉ์„ ์‹œ์ž‘ํ•˜๋Š” ๋ถ„๋“ค๋„ ์ž˜ ์•„๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด๋ผ๊ณ  ์ƒ๊ฐํ•œ๋‹ค. ์—ฌ๋Ÿฌ ๊ฐ€์ง€ ์ข…๋ฅ˜์˜ ์ •๋ ฌ ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด ์žˆ์ง€๋งŒ Python์˜ ๋‚ด์žฅํ•จ์ˆ˜ Sort์™€ Sorted๋ฅผ ํ•จ๊ป˜ ์‚ดํŽด๋ณด๋„๋ก ํ•˜์ž ํŒŒ์ด์ฌ์ด ์ œ๊ณตํ•˜๋Š” ์ž๋ฃŒ๊ตฌ์กฐ..

    [Python | week1-2] Greedy ์•Œ๊ณ ๋ฆฌ์ฆ˜ | ์ด๊ฒƒ์ด ์ฝ”๋”ฉํ…Œ์ŠคํŠธ๋‹ค

    week1-2 [์˜ค๋Š˜์˜ ํ•™์Šต] 1. Greedy ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๊ฐœ๋… 2. '์ฒด์œก๋ณต' ๋ฌธ์ œ ํ’€์ด 3. ๊ทธ๋ฆฌ๋”” ์•Œ๊ณ ๋ฆฌ์ฆ˜ ์ถ”์ฒœ ํ•™์Šต 1. Greedy Algorithm ๊ฐœ๋… ์ด๋ฆ„๊ณผ ๊ฐ™์ด ํƒ์š•์Šค๋Ÿฌ์šด ๋ฐฉ๋ฒ•์œผ๋กœ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค. ๋ˆˆ์•ž์— ๋†“์ธ ์„ ํƒ์ง€ ์ค‘ ํ•ญ์ƒ ๋” ์ข‹์€ ๊ฒƒ์„ ์„ ํƒํ•ด ๋‚˜๊ฐ‘๋‹ˆ๋‹ค - ์•Œ๊ณ ๋ฆฌ์ฆ˜ ์ค‘ ๊ธฐ๋ณธ์— ํ•ด๋‹นํ•ฉ๋‹ˆ๋‹ค. (ํ•˜์ง€๋งŒ ์‰ฝ๋‹ค๋Š” ๊ฒƒ์„ ์•„๋‹˜) - ํ˜„์žฌ์˜ ์ตœ์  ๊ฐ’์ด ์ตœ์ข… ์ตœ์  ๊ฐ’์— ์˜ํ–ฅ์„ ์ฃผ์ง€ ์•Š์„ ๋•Œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. - ํ•œ ๋ฒˆ ํ•œ ์„ ํƒ์„ ์ทจ์†Œํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. - ๋„์ถœ ๋œ ๊ฐ’์ด ํ•ด๋‹น ๋ฌธ์ œ์˜ ์ตœ์ ๊ฐ’์ธ์ง€๋Š” ์•Œ ๋ฐฉ๋ฒ•์ด ์—†์Šต๋‹ˆ๋‹ค. ( ๊ทธ๋ž˜์„œ NP-Hard์—์„œ ์ž์ฃผ ์‚ฌ์šฉ ๋จ) 2. ๋ฌธ์ œ ํ’€์ด ์•„์‰ฝ๊ฒŒ๋„ ๊ณต๊ฐœ๋œ ๋ฌธ์ œ๊ฐ€ ์•„๋‹ˆ๋ฏ€๋กœ ์–ด๋–ค ๋ฌธ์ œ ์ธ์ง€ ์œ ์ถ”ํ•  ์ˆ˜ ์—†๋„๋ก ์ž‘์„ฑํ•˜๋Š” ๊ฒƒ์ด ์›์น™์ด๋ผ ๋ฌธ์ œ ์„ค๋ช…์€ ์—†์Šต๋‹ˆ๋‹ค. ํ’€์ด..