ํฌ์ŠคํŒ… ์ธ๋„ค์ผ ์ด๋ฏธ์ง€

CTF

[DawgCTF 2021] :pwn: Jellyspotters Write-Up

Jellyspotters - 100pts Description Tag pwnable, pickle, python Problem Analysis ๊ทธ๋ฆผ์„ ๊ทธ๋ฆฌ๋Š” ํ”„๋กœ๊ทธ๋žจ์ด๋„ค์šฉ ๋Œ€์ถฉ ์ด๋Ÿฐ ํ”„๋กœ๊ทธ๋žจ์ด๊ณ  ์ด๊ฒƒ์ €๊ฒƒ ํ•ด๋ดค๋Š”๋ฐ Pickle์„ ์‚ฌ์šฉํ•œ๋‹ค๋Š” ๊ฒƒ์„ ์•Œ ์ˆ˜ ์žˆ๊ตฐ์š” Pickle์€ ์ทจ์•ฝ์ ์ด ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค. ๊ธ€ ์ฒจ๋ถ€ํ•ฉ๋‹ˆ๋‹ค. https://davidhamann.de/2020/04/05/exploiting-python-pickle/ Exploiting Python pickles How unpickling untrusted data can lead to remote code execution. davidhamann.de ๊ทธ๋Ÿผ ์ด๊ฑธ ๊ฐ€์ง€๊ณ  RCE๋ฅผ ํ•ด๋ด…์‹œ๋‹น Exploit ์ž ๊ธฐ๋ณธ์ ์œผ๋กœ pickle์˜ ์ทจ์•ฝ์ ์€ __reduce__..

2021.05.18 ๊ฒŒ์‹œ๋จ

 ํฌ์ŠคํŒ… ์ธ๋„ค์ผ ์ด๋ฏธ์ง€

CTF

[DawgCTF 2021] :pwn: No Step On Snek Write-Up

No Step On Snek - 75pts Description Tag pwnable, python, RCE Problem Analysis ์ ‘์†์„ ํ•˜๋ฉด ์ด๋Ÿฐ ์ฐฝ์ด ๋‚˜ํƒ€๋‚˜๋Š”๋ฐ, ์„ค๋ช…์— ์“ฐ์—ฌ์ ธ์žˆ๋Š” ํ‚ค๋ฅผ ๋ˆŒ๋Ÿฌ๋„ ์•„๋ฌด๊ฒƒ๋„ ์‹คํ–‰์ด ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ ์ด์ƒํ•œ ๊ฐ’์„ ์ง‘์–ด๋„ฃ๋Š” ๊ฒฝ์šฐ์—๋Š” ์ด๋Ÿฐ๊ฒŒ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค. ๋ณด์•„ํ•˜๋‹ˆ, make_move(maze)๋ผ๋Š” ๋ช…๋ น์–ด๊ฐ€ ์‹คํ–‰์ด ๋˜๊ณ , ์ด๋•Œ maze๋ผ๋Š” ๊ฒƒ์€ ์ €ํฌ์˜ ์ž…๋ ฅ์ธ ๊ฒƒ์„ ์•Œ ์ˆ˜ ์žˆ๋„ค์š”. ์ด ์ ์„ ์ด์šฉํ•ด์„œ code injection์„ ์‹คํ–‰์‹œ์ผœ์ฃผ๋ฉด ์ข‹์ง€ ์•Š์„๊นŒ ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค. Exploit ๊ทธ๋ž˜์„œ ํ™•์ธ์„ ์šฐ์„  ํ•ด ๋ด…์‹œ๋‹ค! __builtins__.__dict__['__import__']("os").system("ls") ์ž˜ ์‹คํ–‰์ด ๋˜๋„ค์š”. ๊ทธ๋ž˜์„œ ๋ฐ”๋กœ flag.txt๋ฅผ ์—ด์–ด๋ณด๋ฉด __..

2021.05.14 ๊ฒŒ์‹œ๋จ

 ํฌ์ŠคํŒ… ์ธ๋„ค์ผ ์ด๋ฏธ์ง€

SYSTEM HACKING/PWNABLE

[Python] Built-in ๊ฐ์ฒด ์‚ฌ์šฉํ•˜๊ธฐ, ์‘์šฉํ•˜๊ธฐ (Python RCE)

Built-in ๊ฐ์ฒด ์‚ฌ์šฉํ•˜๊ธฐ, ์‘์šฉํ•˜๊ธฐ (for CTF) Python built-in functions (Python RCE) ์š”์ฆ˜ python์œผ๋กœ ํฌ๋„ˆ๋ธ” ๋ฌธ์ œ๊ฐ€ ๋งŽ์ด ๋‚˜์˜ค๋˜๋ฐ, ์™ ๋งŒํ•˜๋ฉด ์ด๊ฑฐ ๊ด€๋ จ ๋ฌธ์ œ๋“ค์ด์—ฌ์„œ ํ•œ๋ฒˆ ์ •๋ฆฌํ•˜๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹น 1. __builtin__ ๊ฐ์ฒด ์†Œ๊ฐœ ์ผ๋‹จ 'built-in'ํ•จ์ˆ˜๋ผ๋Š”๊ฑด ๋ˆ„๊ตฌ๋‚˜ ์•Œ๊ณ  ์žˆ๋‹ค๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค. ๊ทธ python์—์„œ ๊ธฐ๋ณธ์ ์œผ๋กœ ์ œ๊ณตํ•˜๋Š” ๊ทธ ํ•จ์ˆ˜๋“ค ๋งž์•„์œ ! ๋” ์ค‘์š”ํ•˜๊ฒŒ ๋ด์•ผํ•  ๊ฑด built-in ๊ฐ์ฒด์ž…๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, builtins.open ์€ ๋‚ด์žฅ ํ•จ์ˆ˜ open() ์˜ ์™„์ „ํ•œ ์ด๋ฆ„์ž…๋‹ˆ๋‹ค. ์ด๋ ‡๊ฒŒ ๋ชจ๋“  ๋‚ด์žฅ ์‹๋ณ„์ž๋ฅผ ์—ฐ๊ฒฐํ•˜๋Š” ์•ก์„ธ์Šค๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ์–ด๋ ค์›Œ ๋ณด์ผ ์ˆ˜ ์žˆ๋Š”๋ฐ ์‚ฌ์‹ค ์šฐ๋ฆฌ๊ฐ€ ํ‰์†Œ์— ์‚ฌ์šฉํ•˜๋˜ ๊ฒƒ๋“ค์ž…๋‹ˆ๋‹ค. ํ˜น์‹œ๋‚˜ ๋” ๊ถ๊ธˆํ•˜์‹  ๋ถ„๋“ค์€ ์—ฌ๊ธฐ๋กœ #1. Using ..

2021.05.14 ๊ฒŒ์‹œ๋จ

 ํฌ์ŠคํŒ… ์ธ๋„ค์ผ ์ด๋ฏธ์ง€

Coding_Algorithm/C_C++

[์žฌ๊ท€ํ•จ์ˆ˜] ์žฌ๊ท€ํ•จ์ˆ˜ ๊ตฌํ˜„ํ•  ๋•Œ ์—ผ๋‘์— ๋‘๋ฉด ์ข‹์€ ๊ฒƒ๋“ค

์ž‘๋…„์— c์–ธ์–ด๋ฅผ ์ฒ˜์Œ ๋ฐฐ์šธ ๋•Œ๋„ ์žฌ๊ท€ํ•จ์ˆ˜์— ๋Œ€ํ•ด์„œ ๋ฐฐ์› ๋Š”๋ฐ ๋„ˆ๋ฌด ์–ด๋ ค์›Œ์„œ ๊ทธ๋ƒฅ ๋ฌด์‹œํ•œ ์ ์ด ์žˆ์—ˆ๋Š”๋ฐ ๋ฌผ๋ก  ๊ทธ๋žฌ๋‹ค๊ฐ€ ์ง€๊ธˆ ์ถฉ๋ถ„ํžˆ ๊ณ ํ†ต์„ ๋ฐ›์„ ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ ์žฌ๊ท€ํ•จ์ˆ˜์™€ ํ•จ๊ป˜ ์ง€์ง€๊ณ  ๋ณถ๊ณ  ํ•˜๋‹ค๊ฐ€ ๊ฒฐ๊ตญ ์—ฌ๋Ÿฌ๊ฐ€์ง€๋ฅผ ๊นจ๋‹ฌ์„ ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.. ์•„์ง ์ €๋„ ์ œ๋Œ€๋กœ ์•„๋Š”๊ฑด ์•„๋‹ˆ์ง€๋งŒ ๋ฐœ์ƒํ•˜๋Š” ๋ฐฉ๋ฒ• ์ž์ฒด๋ฅผ ์ •๋ฆฌํ•˜๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™๋„ค์š”! ๋ฐœ์ƒ์— ๋„์›€๋˜๋Š” ๊ฒƒ ์ผ๋‹จ ์žฌ๊ท€ํ•จ์ˆ˜๋ฅผ ์–ด๋ ค์›Œํ•˜๋Š” ์‚ฌ๋žŒ๋“ค์˜ ํŠน์ง•์€(๋‚˜๋„๊ทธ๋žฌ๊ณ ) ์žฌ๊ท€๊ฐ€ ์ผ์–ด๋‚˜๋Š” ์•ˆ์ชฝ์—์„œ ์–ด๋–ป๊ฒŒ ์ง„ํ–‰์ด ๋˜๋Š”๊ฐ€ ์— ๋Œ€ํ•ด์„œ ๊ถ๊ธˆํ•ดํ•œ๋‹ค๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.. ๋ฌผ๋ก  ์•Œ๋ฉด ์ข‹๊ฒ ์ง€๋งŒ, ์žฌ๊ท€๊ฐ€ 3์ค‘, 4์ค‘์œผ๋กœ ๊ฒน๊ฒน์ด ์ง„ํ–‰๋˜๋ฉด ๋จธ๋ฆฌ๊ฐ€ ์Šฌ์Šฌ ์•„ํŒŒ์˜ค๊ณ , ํฌ๊ธฐ๋ฅผ ํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ ์žฌ๊ท€ํ•จ์ˆ˜์—์„œ ์ง„์งœ ํ•ต์‹ฌ์€ ์žฌ๊ท€ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•จ์œผ๋กœ์จ ์žฌ๊ท€ํ•จ์ˆ˜๊ฐ€ ํ•˜๋Š” ์—ญํ•  ์„ ํŒŒ์•…ํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์šฐ๋ฆฌ๊ฐ€ ๊ตณ์ด ์žฌ๊ท€ํ•จ์ˆ˜๋ฅผ ๋‹ค ..

2020.05.02 ๊ฒŒ์‹œ๋จ

 ํฌ์ŠคํŒ… ์ธ๋„ค์ผ ์ด๋ฏธ์ง€

Coding_Algorithm/Python

[repl.it] 4.7. For: Number of zeros Solutions/ํ’€์ด

๋ช‡๊ฐœ๋ฅผ ์ž…๋ ฅ๋ฐ›์„์ง€ ์ž…๋ ฅ๋ฐ›์•„ ์ •ํ•œ ํ›„, 0์ด๋ผ๊ณ  ์ž…๋ ฅํ•œ ๊ฐฏ์ˆ˜๋ฅผ ์„ธ๋ผ๊ณ  ํ•˜๋„ค์š”. N = int(input()) cnt=0 for i in range(N): if(int(input()) == 0): cnt += 1; print(cnt) ์‚ฌ์‹ค if๋ฌธ ์กฐ๊ฑด์„ ์ €๋ ‡๊ฒŒ ๊ด„ํ˜ธ๋กœ ์•ˆ์”Œ์›Œ์ค˜๋„ ๋ฉ๋‹ˆ๋‹ค. ๊ทผ๋ฐ C์–ธ์–ด๋ฅผ ํ•˜๋˜ ๊ด€์„ฑ์ด ๋‚จ์•„์žˆ์–ด์„œ.. ์•„ ์ฐธ๊ณ ๋กœ python3์—์„œ๋Š” C์–ธ์–ด์—์„œ์˜ ++์ด ์—†๋‹ค๋Š”๊ฑฐ ์•Œ์•„๋‘์„ธ์š”. (1์„ ๋”ํ•ด์ฃผ๋Š” ๊ธฐ๋Šฅ)

2020.03.17 ๊ฒŒ์‹œ๋จ

 ํฌ์ŠคํŒ… ์ธ๋„ค์ผ ์ด๋ฏธ์ง€

Coding_Algorithm/์ •์˜ฌ ๋ฌธ์ œํ’€์ด

[์ •์˜ฌ] ๊ธฐ์ดˆ๋‹ค์ง€๊ธฐ_์ถœ๋ ฅ_์ž๊ฐ€์ง„๋‹จ2_code502 (C/C++/Python)

502 : ์ถœ๋ ฅ - ์ž๊ฐ€์ง„๋‹จ2 ์ œํ•œ์‹œ๊ฐ„: 1000 ms ๋ฉ”๋ชจ๋ฆฌ์ œํ•œ: 0 MB ํ•ด๊ฒฐํšŸ์ˆ˜: 17125 ํšŒ ์‹œ๋„ํšŸ์ˆ˜: 27418 ํšŒ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ถœ๋ ฅ๋˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜๋ผ. Programming! It's fun. 1. C์–ธ์–ด #include int main() { printf("Programming! It's fun."); return 0; } 2. C++ #include using namespace std; int main() { cout

2019.11.03 ๊ฒŒ์‹œ๋จ

 ํฌ์ŠคํŒ… ์ธ๋„ค์ผ ์ด๋ฏธ์ง€

Coding_Algorithm/์ •์˜ฌ ๋ฌธ์ œํ’€์ด

[์ •์˜ฌ] ๊ธฐ์ดˆ๋‹ค์ง€๊ธฐ_์ถœ๋ ฅ_์ž๊ฐ€์ง„๋‹จ1_code501 (c/c++/python)

501 : ์ถœ๋ ฅ - ์ž๊ฐ€์ง„๋‹จ1 ์ œํ•œ์‹œ๊ฐ„: 1000 ms ๋ฉ”๋ชจ๋ฆฌ์ œํ•œ: 0 MB ํ•ด๊ฒฐํšŸ์ˆ˜: 22573 ํšŒ ์‹œ๋„ํšŸ์ˆ˜: 48950 ํšŒ ์•„๋ž˜ "์ถœ๋ ฅ์˜ˆ"์™€ ๊ฐ™์ด ์ถœ๋ ฅ๋˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜๋ผ. Fun Programming! 1. C์–ธ์–ด #include int main() { printf("Fun Programming!"); return 0; } 2. C++ #include using namespace std; int main() { cout

2019.11.03 ๊ฒŒ์‹œ๋จ

 ํฌ์ŠคํŒ… ์ธ๋„ค์ผ ์ด๋ฏธ์ง€

Coding_Algorithm/๋ฐฑ์ค€ ํ’€์ด

๋ฐฑ์ค€ 10699๋ฒˆ: ์˜ค๋Š˜ ๋‚ ์งœ ํ’€์ด(Python)

์˜ค๋Š˜ ๋‚ ์งœ ์ŠคํŽ˜์…œ ์ €์ง€ ์‹œ๊ฐ„ ์ œํ•œ๋ฉ”๋ชจ๋ฆฌ ์ œํ•œ์ œ์ถœ์ •๋‹ต๋งž์€ ์‚ฌ๋žŒ์ •๋‹ต ๋น„์œจ 1 ์ดˆ 256 MB 6038 3780 3458 65.817% ๋ฌธ์ œ ์„œ์šธ์˜ ์˜ค๋Š˜ ๋‚ ์งœ๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. ์ž…๋ ฅ ์ž…๋ ฅ์€ ์—†๋‹ค. ์ถœ๋ ฅ ์„œ์šธ์˜ ์˜ค๋Š˜ ๋‚ ์งœ๋ฅผ "YYYY-MM-DD" ํ˜•์‹์œผ๋กœ ์ถœ๋ ฅํ•œ๋‹ค. ์˜ˆ์ œ ์ž…๋ ฅ 1 ๋ณต์‚ฌ ์˜ˆ์ œ ์ถœ๋ ฅ 1 ๋ณต์‚ฌ 2015-01-24 ๋ฌผ๋ก  ๊ทธ๋ƒฅ ์ € ํ˜•์‹์œผ๋กœ ์˜ค๋Š˜ ๋‚ ์งœ๋ฅผ printํ•ด๋ฒ„๋ฆฌ๋ฉด ๋˜์ง€๋งŒ, ๋” ์ œ๋Œ€๋กœ๋œ ๋ฐฉ์‹์œผ๋กœ ์•Œ์•„๋ณด์ž. import datetime print(str(datetime.datetime.now())[:10]) ๋ฌผ๋ก  ๊ทธ๋ ‡๊ฒŒ ์•Œ์•„๋ณธ ์ฝ”๋“œ๋„ ๊ฐœ์งง๋‹ค. ๊ฐ€๋ณ๊ฒŒ ์„ค๋ช…์„ ํ•ด๋ณด์ž๋ฉด datetime, ์ฆ‰ ์šฐ๋ฆฌ๊ฐ€ ํ•„์š”ํ•œ ํ•จ์ˆ˜๋ฅผ ๋“ค๊ณ ์˜ค๊ณ  ๊ทธ๊ฒƒ์„ string์œผ๋กœ print์‹œํ‚ฌ๊ฑด๋ฐ 10๊ธ€์ž๋งŒ ์ถœ๋ ฅ์‹œํ‚จ๊ฒƒ์ด๋‹ค.

2019.06.13 ๊ฒŒ์‹œ๋จ

 ํฌ์ŠคํŒ… ์ธ๋„ค์ผ ์ด๋ฏธ์ง€

Coding_Algorithm/๋ฐฑ์ค€ ํ’€์ด

๋ฐฑ์ค€ 11022๋ฒˆ: A + B - 8ํ’€์ด(Python)

A+B - 8 ์‹œ๊ฐ„ ์ œํ•œ๋ฉ”๋ชจ๋ฆฌ ์ œํ•œ์ œ์ถœ์ •๋‹ต๋งž์€ ์‚ฌ๋žŒ์ •๋‹ต ๋น„์œจ 1 ์ดˆ 256 MB 9976 7258 6744 74.306% ๋ฌธ์ œ ๋‘ ์ •์ˆ˜ A์™€ B๋ฅผ ์ž…๋ ฅ๋ฐ›์€ ๋‹ค์Œ, A+B๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. ์ž…๋ ฅ ์ฒซ์งธ ์ค„์— ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค์˜ ๊ฐœ์ˆ˜ T๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. ๊ฐ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๋Š” ํ•œ ์ค„๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ์œผ๋ฉฐ, ๊ฐ ์ค„์— A์™€ B๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. (0 < A, B < 10) ์ถœ๋ ฅ ๊ฐ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๋งˆ๋‹ค "Case #x: A + B = C" ํ˜•์‹์œผ๋กœ ์ถœ๋ ฅํ•œ๋‹ค. x๋Š” ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค ๋ฒˆํ˜ธ์ด๊ณ  1๋ถ€ํ„ฐ ์‹œ์ž‘ํ•˜๋ฉฐ, C๋Š” A+B์ด๋‹ค. ์˜ˆ์ œ ์ž…๋ ฅ 1 ๋ณต์‚ฌ 5 1 1 2 3 3 4 9 8 5 2 ์˜ˆ์ œ ์ถœ๋ ฅ 1 ๋ณต์‚ฌ Case #1: 1 + 1 = 2 Case #2: 2 + 3 = 5 Case #3: 3 + 4 = 7 Case #4: 9 ..

2019.06.13 ๊ฒŒ์‹œ๋จ

 ํฌ์ŠคํŒ… ์ธ๋„ค์ผ ์ด๋ฏธ์ง€

Coding_Algorithm/๋ฐฑ์ค€ ํ’€์ด

๋ฐฑ์ค€ 11021๋ฒˆ: A + B - 7ํ’€์ด(Python)

t = int(input()) for i in range(t): a, b = map(int, input().split()) print('Case #'+int(i+1)+': '+int(a+b)) ์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ๋Ÿฐํƒ€์ž„ ์—๋Ÿฌ๊ฐ€ ์ผ์–ด๋‚œ๋‹ค. ์ด ์ด์œ ๋Š” inputํ•จ์ˆ˜๊ฐ€ ์‹œ๊ฐ„์„ ๋„ˆ๋ฌด ๋งŽ์ด ์žก์•„๋จน๊ธฐ ๋•Œ๋ฌธ์ธ๋ฐ, ์ด๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด sys.stdin.readlineํ•จ์ˆ˜๋ฅผ ์ด์šฉํ•˜์˜€๋‹ค. ๋ฐ‘์˜ ์ฝ”๋“œ๋Š” sys.stdin.realine์ด ๋„ˆ๋ฌด ๊ธธ์–ด์„œ readํ•จ์ˆ˜๋ผ๋Š” ๋‹ค๋ฅธ ํ•จ์ˆ˜๋ฅผ ๋”ฐ๋กœ ์„ ์–ธํ•ด์ฃผ๊ณ  ์ฝ”๋“œ๋ฅผ ๋‹ค์‹œ ์ž‘์„ฑํ•œ ๊ฒƒ์ด๋‹ค. import sys read = sys.stdin.readline t = int(read()) for i in range(t): ab = [int(x) for x in read().split()] print("Ca..

2019.06.13 ๊ฒŒ์‹œ๋จ

 ํฌ์ŠคํŒ… ์ธ๋„ค์ผ ์ด๋ฏธ์ง€

Coding_Algorithm/๋ฐฑ์ค€ ํ’€์ด

๋ฐฑ์ค€ 2163๋ฒˆ: ์ดˆ์ฝœ๋ฆฟ ์ž๋ฅด๊ธฐ ํ’€์ด(Python)

์ดˆ์ฝœ๋ฆฟ ์ž๋ฅด๊ธฐ ์‹œ๊ฐ„ ์ œํ•œ๋ฉ”๋ชจ๋ฆฌ ์ œํ•œ์ œ์ถœ์ •๋‹ต๋งž์€ ์‚ฌ๋žŒ์ •๋‹ต ๋น„์œจ 2 ์ดˆ 128 MB 10798 7589 6540 71.679% ๋ฌธ์ œ ์ •ํ™”๋Š” Nร—M ํฌ๊ธฐ์˜ ์ดˆ์ฝœ๋ฆฟ์„ ํ•˜๋‚˜ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค. ์ดˆ์ฝœ๋ฆฟ์€ ๊ธˆ์ด ๊ฐ€ ์žˆ๋Š” ๋ชจ์–‘์„ ํ•˜๊ณ  ์žˆ์œผ๋ฉฐ, ๊ทธ ๊ธˆ์— ์˜ํ•ด Nร—M๊ฐœ์˜ ์กฐ๊ฐ์œผ๋กœ ๋‚˜๋ˆ ์งˆ ์ˆ˜ ์žˆ๋‹ค. ์ดˆ์ฝœ๋ฆฟ์˜ ํฌ๊ธฐ๊ฐ€ ๋„ˆ๋ฌด ํฌ๋‹ค๊ณ  ์ƒ๊ฐํ•œ ๊ทธ๋…€๋Š” ์ดˆ์ฝœ๋ฆฟ์„ ์นœ๊ตฌ๋“ค๊ณผ ๋‚˜๋ˆ  ๋จน๊ธฐ๋กœ ํ–ˆ๋‹ค. ์ด๋ฅผ ์œ„ํ•ด์„œ ์ •ํ™”๋Š” ์ดˆ์ฝœ๋ฆฟ์„ ๊ณ„์† ์ชผ๊ฐœ์„œ ์ด Nร—M๊ฐœ์˜ ์กฐ๊ฐ์œผ๋กœ ์ชผ๊ฐœ๋ ค๊ณ  ํ•œ๋‹ค. ์ดˆ์ฝœ๋ฆฟ์„ ์ชผ๊ฐค ๋•Œ์—๋Š” ์ดˆ์ฝœ๋ฆฟ ์กฐ๊ฐ์„ ํ•˜๋‚˜ ๋“ค๊ณ , ์ ๋‹นํ•œ ์œ„์น˜์—์„œ ์ดˆ์ฝœ๋ฆฟ์„ ์ชผ๊ฐ ๋‹ค. ์ดˆ์ฝœ๋ฆฟ์„ ์ชผ๊ฐค ๋•Œ์—๋Š” ๊ธˆ์ด ๊ฐ€ ์žˆ๋Š” ์œ„์น˜์—์„œ๋งŒ ์ชผ๊ฐค ์ˆ˜ ์žˆ๋‹ค. ์ด์™€ ๊ฐ™์ด ์ดˆ์ฝœ๋ฆฟ์„ ์ชผ๊ฐœ๋ฉด ์ดˆ์ฝœ๋ฆฟ์€ ๋‘ ๊ฐœ์˜ ์กฐ๊ฐ์œผ๋กœ ๋‚˜๋ˆ ์ง€๊ฒŒ ๋œ๋‹ค. ์ด์ œ ๋‹ค์‹œ ์ด ์ค‘์—์„œ ์ดˆ์ฝœ๋ฆฟ ์กฐ๊ฐ์„ ํ•˜๋‚˜ ๋“ค๊ณ , ์ชผ๊ฐœ๋Š” ๊ณผ์ •์„..

2019.06.13 ๊ฒŒ์‹œ๋จ

 ํฌ์ŠคํŒ… ์ธ๋„ค์ผ ์ด๋ฏธ์ง€

Coding_Algorithm/๋ฐฑ์ค€ ํ’€์ด

๋ฐฑ์ค€ 3046๋ฒˆ: R2 ํ’€์ด(Python)

R2 ์„ฑ๊ณต ํ•œ๊ตญ์–ด ์‹œ๊ฐ„ ์ œํ•œ๋ฉ”๋ชจ๋ฆฌ ์ œํ•œ์ œ์ถœ์ •๋‹ต๋งž์€ ์‚ฌ๋žŒ์ •๋‹ต ๋น„์œจ 1 ์ดˆ 128 MB 6939 5822 5374 85.492% ๋ฌธ์ œ ๋‘ ์ˆซ์ž R1๊ณผ R2๊ฐ€ ์žˆ์„ ๋•Œ, ๋‘ ์ˆ˜์˜ ํ‰๊ท  S๋Š” (R1+R2)/2์™€ ๊ฐ™๋‹ค. ์ƒ๊ทผ์ด๋Š” ์ •์ธ์ด ์ƒ์ผ ์„ ๋ฌผ๋กœ ๋‘ ์ˆซ์ž R1๊ณผ R2๋ฅผ ์ฃผ๋ ค๊ณ  ํ•œ๋‹ค. ์ƒ์ผ ํŒŒํ‹ฐ์—์„œ ์ƒ๊ทผ์ด๋Š” ์ •์ธ์ด์—๊ฒŒ ์ด ๋‘ ์ˆซ์ž๋ฅผ ๋งํ•ด์ฃผ๊ณ , ์ •์ธ์ด๋Š” ์ด ์ˆซ์ž๋ฅผ ๋ฐ›์•„ ์ ๋Š”๋‹ค. ๊ทธ๋ฆฌ๊ณ  ๋‚˜์„œ ๊ธฐ์œ ๋งˆ์Œ์œผ๋กœ 1๋…„๋™์•ˆ ์ด ์ˆซ์ž๋ฅผ ์™ธ์šฐ๋ฉด์„œ ์‚ฐ๋‹ค. ์ƒ๊ทผ์ด๋Š” R1๊ณผ R2๋ฅผ ์—„์ฒญ๋‚œ ๊ณ ๋ฏผ ๋์— ์ •ํ–ˆ๋‹ค. ์ž‘๋…„์—๋Š” R1๊ณผ R2๋ฅผ ๊นŒ๋จน์–ด์„œ ์•„๋ฌด ์ˆซ์ž๋‚˜ ์ •ํ•ด์„œ ์ฃผ์—ˆ๊ธฐ ๋•Œ๋ฌธ์—, ์˜ฌํ•ด๋Š” ๊นŒ๋จน์ง€ ์•Š๊ธฐ ์œ„ํ•ด์„œ ํ‰๊ท  S๋„ ๊ฐ™์ด ๊ธฐ์–ตํ•˜๋ ค๊ณ  ํ•œ๋‹ค. ์˜ค๋Š˜์€ ์ •์ธ์ด ์ƒ์ผ์ด๋‹ค. 5๋ถ„ ํ›„์— ์ƒ๊ทผ์ด๋Š” ์ƒ์ผ ์„ ๋ฌผ๋กœ ๋‘ ์ˆซ์ž R1๊ณผ R2๋ฅผ ๋งํ•ด์ฃผ์–ด์•ผ ํ•˜์ง€๋งŒ, ..

2019.06.13 ๊ฒŒ์‹œ๋จ