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

[BAEKJOON/ ๋ฐฑ์ค€] 2231๋ฒˆ: ๋ถ„ํ•ดํ•ฉ

https://www.acmicpc.net/problem/2231 [1] ๋ฌธ์ œ ํ’€์ด n = int(input()) # ๋ถ„ํ•ดํ•ฉ์„ ์ž…๋ ฅ๊ฐ’์œผ๋กœ ๋ฐ›์Œfor i in range(1, n+1): # ํ•ด๋‹น ๋ถ„ํ•ดํ•ฉ์˜ ์ƒ์„ฑ์ž ์ฐพ๊ธฐ num = sum((map(int, str(i)))) # i์˜ ๊ฐ ์ž๋ฆฟ์ˆ˜๋ฅผ ๋”ํ•จ num_sum = i + num # ๋ถ„ํ•ดํ•ฉ = ์ƒ์„ฑ์ž + ๊ฐ ์ž๋ฆฟ์ˆ˜์˜ ํ•ฉ # i๊ฐ€ ์ž‘์€ ์ˆ˜๋ถ€ํ„ฐ ์ฐจ๋ก€๋กœ ๋“ค์–ด๊ฐ€๋ฏ€๋กœ ์ฒ˜์Œ์œผ๋กœ ๋ถ„ํ•ดํ•ฉ๊ณผ ์ž…๋ ฅ๊ฐ’์ด ๊ฐ™์„๋•Œ๊ฐ€ ๊ฐ€์žฅ ์ž‘์€ ์ƒ์„ฑ์ž๋ฅผ ๊ฐ€์ง if num_sum == n: print(i) break if i == n: # ์ƒ์„ฑ์ž i์™€ ์ž…๋ ฅ๊ฐ’์ด ๊ฐ™๋‹ค๋Š” ๊ฒƒ์€ ์ƒ์„ฑ์ž๊ฐ€ ์—†๋‹ค๋Š” ๋œป print(0)  n = int(i..

[BAEKJOON/๋ฐฑ์ค€] 2798๋ฒˆ: ๋ธ”๋ž™์žญ

N, M = map(int, input().split()) cards = list(map(int, input().split())) max_sum = 0 # ์ตœ๋Œ€ ํ•ฉ ์ดˆ๊ธฐํ™”# ๋ชจ๋“  ์นด๋“œ์˜ ์กฐํ•ฉ์„ ํƒ์ƒ‰for i in range(N - 2): for j in range(i + 1, N - 1): for k in range(j + 1, N): card_sum = cards[i] + cards[j] + cards[k] if card_sum max_sum: max_sum = card_sum print(max_sum) https://www.acmicpc.net/problem/2798[1] ๋ฌธ์ œ ํ’€์ด ์ด ๋ฌธ์ œ๋Š” N์žฅ์˜ ์นด๋“œ ์ค‘์—..

[Dreamhack/๋“œ๋ฆผํ•ต] baby-union

https://dreamhack.io/wargame/challenges/984 baby-unionDescription ๋กœ๊ทธ์ธ ์‹œ ๊ณ„์ •์˜ ์ •๋ณด๊ฐ€ ์ถœ๋ ฅ๋˜๋Š” ์›น ์„œ๋น„์Šค์ž…๋‹ˆ๋‹ค. SQL INJECTION ์ทจ์•ฝ์ ์„ ํ†ตํ•ด ํ”Œ๋ž˜๊ทธ๋ฅผ ํš๋“ํ•˜์„ธ์š”. ๋ฌธ์ œ์—์„œ ์ฃผ์–ด์ง„ init.sql ํŒŒ์ผ์˜ ํ…Œ์ด๋ธ”๋ช…๊ณผ ์ปฌ๋Ÿผ๋ช…์€ ์‹ค์ œ ์ด๋ฆ„๊ณผ ๋‹ค๋ฆ…๋‹ˆ๋‹ค. ํ”Œ๋ž˜dreamhack.io[1] ๋ฌธ์ œ ์„ค๋ช…     ์šฐ์„  SQL INJECTION ์ทจ์•ฝ์ ์„ ์ด์šฉํ•˜์—ฌ ์œ„์™€ ๊ฐ™์€ ์ž…๋ ฅ๊ฐ’์„ ์ œ์ถœํ•ด์ฃผ์—ˆ๋‹ค.admin ๊ณ„์ •์œผ๋กœ ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ์—ˆ๊ณ , ๋ณ„ ์˜๋ฏธ ์—†๋Š” ํ…Œ์ด๋ธ”์„ ๋ณผ ์ˆ˜ ์žˆ์—ˆ๋‹ค...  app.py๋ฅผ ์‚ดํŽด๋ณด์ž.import osfrom flask import Flask, request, render_templatefrom flask_mysqldb import MySQLa..

[Dreamhack/๋“œ๋ฆผํ•ต] PHPreg

https://dreamhack.io/wargame/challenges/873 phpregDescription php๋กœ ์ž‘์„ฑ๋œ ํŽ˜์ด์ง€์ž…๋‹ˆ๋‹ค. ์•Œ๋งž์€ Nickname๊ณผ Password๋ฅผ ์ž…๋ ฅํ•˜๋ฉด Step 2๋กœ ๋„˜์–ด๊ฐˆ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Step 2์—์„œ system() ํ•จ์ˆ˜๋ฅผ ์ด์šฉํ•˜์—ฌ ํ”Œ๋ž˜๊ทธ๋ฅผ ํš๋“ํ•˜์„ธ์š”. ํ”Œ๋ž˜๊ทธ๋Š” ../dream/flag.txt์— ์œ„์น˜ํ•ฉ๋‹ˆdreamhack.io[1] ๋ฌธ์ œ ํ’€์ด  ๋ฌธ์ œ ์„ค๋ช…์„ ๋‹ค์‹œ ๋ณด์ž๋ฉด, ์ด๋Ÿฌํ•˜๋‹ค! ๊ทธ๋Ÿฌ๋‹ˆ๊นŒ php๋กœ ์ž‘์„ฑํ•œ ํŽ˜์ด์ง€์— ์ ‘์†์„ ํ•˜๋ฉด, Ncickname๊ณผ Password๋ฅผ ์ž…๋ ฅํ•  ์ˆ˜ ์žˆ๋Š” ํ™”๋ฉด์ด ๋‚˜์˜จ๋‹ค.๋จผ์ € ์•Œ๋งž์€ Nickname๊ณผ Password๋ฅผ ์ž…๋ ฅํ•˜์—ฌ Step 2๋กœ ๋„˜์–ด๊ฐ€๋ณด์ž!  Step 1 ํŽ˜์ด์ง€์˜ ์†Œ์Šค์ฝ”๋“œ ํŽ˜์ด์ง€๋ฅผ ์‚ดํŽด๋ณด์•˜๋Š”๋ฐ ๋ณ„ ๊ฒŒ ์—†์–ด์„œ ๋ฌธ์ œ ํŒŒ์ผ์„ ์‚ดํŽด..

[๋””์ง€ํ„ธ ํฌ๋ Œ์‹ ์Šคํ„ฐ๋””] 3์ฃผ์ฐจ: ๋ฌธ์ œ ํ’€์ด

์ด๋ฒˆ ์ฃผ ์Šคํ„ฐ๋”” ๋ฒ”์œ„: https://inf.run/zmPL [์ง€๊ธˆ ๋ฌด๋ฃŒ] ๊ธฐ์ดˆ๋ถ€ํ„ฐ ๋”ฐ๋ผํ•˜๋Š” ๋””์ง€ํ„ธํฌ๋ Œ์‹ | ํ›ˆ์ง€์† - ์ธํ”„๋Ÿฐํ›ˆ์ง€์† | ๊ธฐ์ดˆ๋ถ€ํ„ฐ ๋”ฐ๋ผํ•˜๋Š” ๋””์ง€ํ„ธํฌ๋ Œ์‹ ๊ฐ•์˜์ž…๋‹ˆ๋‹ค. ๊ฐ•์˜๋ฅผ ๋”ฐ๋ผํ•˜๋‹ค๋ณด๋ฉด "๋ฌผ ํ๋ฅด๋“ฏ, ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ" ์‹ค๋ ฅ์ด ๋Š˜์–ด๊ฐ€๋Š” ๊ฐ•์˜๋ฅผ ์ถ”๊ตฌํ•ฉ๋‹ˆ๋‹ค., ์ดˆ๋ณด์ž ๋ˆˆ๋†’์ด์— ๋”ฑ ๋งž์ถ˜, ์›๋ฆฌ๋ฅผ ์ดํ•ดํ•˜๋Š” ๋””์ง€ํ„ธwww.inflearn.com  ์ด๋ฏธ์ง€ ์ธํฌ ํ†ตํ•ด ์šด์˜์ฒด์ œ๋ฅผ ์‹๋ณ„ํ•ด์คŒ 1GB ์ •๋„์—ฌ์„œ ์‹๋ณ„ํ•˜๋Š” ๋ฐ์— ์‹œ๊ฐ„์ด ์กฐ๊ธˆ ๊ฑธ๋ฆผ.  netscan: connections, sockets๋ฅผ ํฌํ•จํ•œ ๋” ๋งŽ์€ ๊ธฐ๋Šฅ (Windows xp) connections: "ํ˜„์žฌ ์—ฐ๊ฒฐ๋œ" TCP ํ†ต์‹ ์— ๋Œ€ํ•œ ์ •๋ณด sockets: ์‘๋‹ต๋ฐ›๊ธฐ๋ฅผ ๊ธฐ๋‹ค๋ฆฌ๊ณ  ์žˆ๋Š” ๋ชจ๋“  ํ”„๋กœํ† ์ฝœ์— ๋Œ€ํ•œ socket ์ •๋ณด cmdline: ํ”„๋กœ์„ธ์Šค๊ฐ€ ์‹คํ–‰๋  ..

๋…ผ๋ฌธ ๋ถ„์„: ํด๋ผ์šฐ๋“œ ํ™˜๊ฒฝ์—์„œ ๋ธ”๋ก์ฒด์ธ ๊ธฐ๋ฐ˜์˜ ์›น์„œ๋ฒ„ ๋กœ๊ทธ ๊ด€๋ฆฌ ์‹œ์Šคํ…œ

[1] ๋…ผ๋ฌธ ์„ ์ • ์ด์œ  ์ด์ „์— "๋ธ”๋ก์ฒด์ธ ๊ธฐ๋ฐ˜ ์„ฑ๊ณผ ์ธ์ฆ ์‹œ์Šคํ…œ" ์ฃผ์ œ๋กœ ์ •์ฑ… ์ œ์•ˆ ๊ณต๋ชจ์ „์— ์ œ์ถœํ•œ ๊ฒฝํ—˜์ด ์žˆ๋‹ค. ํ•ด๋‹น ๋ณด๊ณ ์„œ๋Š” ๊ธฐ์—…์ด๋‚˜ ์กฐ์ง ๋‚ด์—์„œ ์ž‘์—…๋ฌผ์„ ์ €์žฅํ•˜๊ณ  ์„ฑ๊ณผ๋ฅผ ์ธ์ฆํ•˜๋Š” ์‹œ์Šคํ…œ์„ ๋ธ”๋ก์ฒด์ธ์˜ ํŠน์ง•์„ ํ™œ์šฉํ•˜์—ฌ ์ œ์•ˆํ–ˆ๋‹ค. ํ˜„์žฌ๋Š” ์˜จ ํ”„๋ ˆ๋ฏธ์Šค ํ™˜๊ฒฝ์—์„œ ํด๋ผ์šฐ๋“œ ํ™˜๊ฒฝ์œผ๋กœ์˜ ์ด์ „๊ณผ ์ด์šฉ์ด ์ฆ๊ฐ€ํ•˜๊ณ  ์žˆ๋Š”๋ฐ, ์ด์— ๋”ฐ๋ผ ํด๋ผ์šฐ๋“œ ํ™˜๊ฒฝ์—์„œ ๋ธ”๋ก์ฒด์ธ์„ ๊ธฐ๋ฐ˜์œผ๋กœ ๋กœ๊ทธ๋ฅผ ๊ด€๋ฆฌํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•œ ๊ถ๊ธˆ์ฆ์ด ์ƒ๊ฒผ๋‹ค.  [2] ๋…ผ๋ฌธ ๋ถ„์„ ๋‚ด์šฉ (1) ์š”์•ฝ ๋ฐ ์„œ๋ก  1. ์†Œ๊ฐœ ํด๋ผ์šฐ๋“œ ํ™˜๊ฒฝ๊ณผ ์›น ์„œ๋น„์Šค ํ™•๋Œ€๋กœ ์‚ฌ์šฉ์ž ๋กœ๊ทธ ๊ด€๋ฆฌ์˜ ์ค‘์š”์„ฑ์ด ์ฆ๋Œ€๋จ. ํ˜„์žฌ์˜ ์ค‘์•™ ์ง‘์ค‘์‹ ๋กœ๊ทธ ๊ด€๋ฆฌ ๋ฐฉ์‹์€ ์™ธ๋ถ€ ๊ณต๊ฒฉ์— ์ทจ์•ฝํ•จ. 2. ๋ฌธ์ œ์  ์ค‘์•™ ์ง‘์ค‘์‹ ๋กœ๊ทธ ๊ด€๋ฆฌ ๋ฐฉ์‹์˜ ์ทจ์•ฝ์„ฑ: ์™ธ๋ถ€ ๊ณต๊ฒฉ์— ์˜ํ•œ ์ •๋ณด ์กฐ์ž‘ ๋ฐ ์œ ์ถœ ์šฐ๋ ค.์›น ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ ๋ฐœ์ƒ..

[BAEKJOON/๋ฐฑ์ค€] 2775๋ฒˆ: ๋ถ€๋…€ํšŒ์žฅ์ด ๋ ํ…Œ์•ผ

[1] ๋ฌธ์ œ ๋ถ„์„ ์ž„์˜์˜ ์ธต๊ณผ ํ˜ธ์ˆ˜๋ฅผ ์ž…๋ ฅ๋ฐ›์œผ๋ฉด, ํ•ด๋‹นํ•˜๋Š” ํ˜ธ์‹ค์— ์‚ฌ๋Š” ์‚ฌ๋žŒ์˜ ์ˆ˜๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•ด์•ผ ํ•œ๋‹ค. "0์ธต์˜ iํ˜ธ์—๋Š” i๋ช…์ด ์‚ฐ๋‹ค." ์กฐ๊ฑด์ด ์ฃผ์–ด์ ธ์žˆ๋‹ค.์ด ์กฐ๊ฑด์— ๋”ฐ๋ผ ๋ฆฌ์ŠคํŠธ์— ์ €์žฅ๋œ ๊ฐ’์„ ์ด์šฉํ•˜์—ฌ ํ‘ธ๋Š” ๋ฐฉ์‹์ผ ๊ฑฐ๋ผ๊ณ  ์ƒ๊ฐํ–ˆ๋‹ค. 3์ธต1621562์ธต1410201์ธต136100์ธต1234 ๊ฐ ํ˜ธ์‹ค์— ์‚ฌ๋Š” ์‚ฌ๋žŒ์˜ ์ˆ˜๋ฅผ ๋ณด๊ธฐ ์ข‹๊ฒŒ ํ‘œ๋กœ ์ •๋ฆฌํ•ด๋ณด์•˜๋‹ค.  [2] ์ฝ”๋“œ  T = int(input())for _ in range(T): k = int(input()) n = int(input()) people = [i for i in range(1, n+1)] for _ in range(k): for i in range(1, n): people[i] +=..

[BAEKJOON/๋ฐฑ์ค€] 9095๋ฒˆ: 1, 2, 3 ๋”ํ•˜๊ธฐ

[1] ํ’€์ด  ์–ด๋–ค ์ˆซ์ž๋ฅผ ์ž…๋ ฅํ•ด๋„ ์›ํ•˜๋Š” ๋Œ€๋กœ์˜ ๊ฒฐ๊ด๊ฐ’์ด ๋‚˜์˜ค๊ฒŒ ํ•˜๋Š” ์–ด๋– ํ•œ ๋‹จ์ผํ•œ(?) ๊ณต์‹์ด ํ•„์š”ํ•œ๊ฐ€...์— ๋Œ€ํ•œ ๊ณ ๋ฏผ์„ ํ–ˆ์—ˆ๋Š”๋ฐ,๊ทœ์น™์— ๋Œ€ํ•ด ๊ณ ๋ฏผํ•ด๋ณธ ๊ฒฐ๊ณผ ์ด ๋ฌธ์ œ๋Š” "DP"๋ฅผ ์ด์šฉํ•ด์„œ ํ‘ธ๋Š” ๋ฌธ์ œ๋‹ค! ๊ทธ๋Ÿฌ๋‹ˆ๊นŒ, ํ”ผ๋ณด๋‚˜์น˜ ์ˆ˜์—ด์ฒ˜๋Ÿผ ํฐ ๋ฌธ์ œ๋ฅผ ์ด๋ฏธ ๋‹ต์„ ๊ตฌํ•œ ์ž‘์€ ๋ฌธ์ œ๋กœ ๋‚˜๋ˆ„์–ด์„œ ํ’€์ดํ•˜๋Š” ๋ฐฉ์‹์„ ์‚ฌ์šฉํ•œ๋‹ค๋Š” ๊ฒƒ์ด๋‹ค. ํ”ผ๋ณด๋‚˜์น˜ ์ˆ˜์—ด์€ f(n) = f(n-1) + f(n-2)๊ณผ ๊ฐ™์ด n๋ฒˆ์งธ ํ•ญ์ด n-1๋ฒˆ์งธ ํ•ญ๊ณผ n-2๋ฒˆ์งธ ํ•ญ์„ ๋”ํ•œ ๊ฐ’์ธ ๊ฒฝ์šฐ์˜€๋Š”๋ฐ,์ด ๋ฌธ์ œ์—์„œ๋Š” ๋น„์Šทํ•˜๊ฒŒ f(n) = f(n-3) + f(n-2) + f(n-1)์™€ ๊ฐ™์€ ๊ทœ์น™์ด ์ ์šฉ์ด ๋œ๋‹ค. (๋‹จ, N>3)  ํ™•์ธ์„ ํ•ด๋ณด๊ฒ ๋‹ค.  1. n=4์ผ ๋•Œ,4๋ฅผ 1, 2, 3์œผ๋กœ ๋”ํ•˜๊ธฐ ๋•Œ๋ฌธ์—, 1+3, 2+2, 3+1๋กœ ๋‚˜๋ˆŒ ์ˆ˜ ์žˆ๋‹ค.1+32+23+1..