๋ฐ˜์‘ํ˜•

๐Ÿ“ฆ Chango 63

[์ฝ”๋ฎค๋‹ˆํ‹ฐ] ์ถ”์„๋งž์ด ์ฝ”๋”ฉ์ฑŒ๋ฆฐ์ง€ 1์ผ์ฐจ : ํ”ผ๋ณด๋‚˜์น˜์ˆ˜

https://cafe.naver.com/codeuniv/44826 [์ถ”์„๋งž์ด ์ฝ”๋”ฉ์ฑŒ๋ฆฐ์ง€โ‘ ] ํ”ผ๋ณด๋‚˜์น˜์ˆ˜ ์ฒซ ๋ฒˆ์งธ ๋ฌธ์ œ์— ๋„์ „ํ•˜๋Ÿฌ ์˜ค์‹  ๋ชจ๋“  ๋ถ„๋“ค ํ™˜์˜ํ•ฉ๋‹ˆ๋‹ค๐Ÿ™Œ ์ถ”์„์—๋„ ์ฝ”๋”ฉํ•˜๋Š” ์—ด์ •๋งจ...๐Ÿฅบ ์ฝ”๋ฎค๊ฐ€ ํ•ญ์ƒ ์‘์›ํ•ฉ๋‹ˆ๋‹ค! ์ฒซ ๋ฒˆ์งธ ๋ฌธ์ œ๋Š” ๋ฐ”๋กœ๋ฐ”๋กœ "ํ”ผ๋ณด๋‚˜์น˜์ˆ˜"์ž…๋‹ˆ๋‹ค~! ์ˆ˜ํ•™๊ณต... cafe.naver.com ์ˆซ์ž n์„ ์ž…๋ ฅ๋ฐ›์•„ ํ”ผ๋ณด๋‚˜์น˜ ์ˆ˜์—ด์˜ n๋ฒˆ์งธ ์ˆซ์ž๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•ด๋ณด์„ธ์š”. #include int main () { int n, ans=0; scanf("%d", &n); if(n==1) ans = 0; else if(n==2) ans = 1; else { int pp=0; int p=1; for(int i=0; i

[์ฝ”๋ฎค๋‹ˆํ‹ฐ] ์ถ”์„๋งž์ด ์ฝ”๋”ฉ์ฑŒ๋ฆฐ์ง€ 2์ผ์ฐจ : ์ •์ƒ ์ •๋ณต

https://cafe.naver.com/codeuniv/44894 [์ถ”์„๋งž์ด ์ฝ”๋”ฉ์ฑŒ๋ฆฐ์ง€โ‘ก] ์ •์ƒ ์ •๋ณต ์ฒซ ๋ฒˆ์งธ ๋ฌธ์ œ๋Š” ์ž˜ ํ’€์–ด๋ณด์…จ๋‚˜์š”? ํ•˜๋ฃจ์— ํ•˜๋‚˜์”ฉ ์ฐจ๊ทผ์ฐจ๊ทผ ๋„์ „ํ•ด๋ด์š”๐Ÿ˜€ ์•„์ง Lv.1 ๋ฌธ์ œ๋ฅผ ํ’€์ง€ ๋ชปํ•ด๋„ ๊ดœ์ฐฎ์•„์š”! Lv.2๋„ ๋„์ „ํ•ด๋ด…์‹œ๋‹ค๐Ÿ”ฅ ๋‘ ๋ฒˆ์งธ ๋ฌธ์ œ๋Š” "์ •์ƒ ์ •๋ณต"... cafe.naver.com ๋‹ฌํŒฝ์ด๋Š” ๋†’์ด๊ฐ€ N์ธ ๋‚˜๋ฌด๋ฅผ ์˜ฌ๋ผ๊ฐ€๊ณ ์ž ํ•œ๋‹ค. ๋‹ฌํŒฝ์ด๋Š” ๋‚ฎ์—๋Š” A๋ฏธํ„ฐ๋ฅผ ์˜ฌ๋ผ๊ฐˆ ์ˆ˜ ์žˆ์ง€๋งŒ, ๋ฐค์— ํœด์‹์„ ์ทจํ•˜๋ฉด์„œ B๋ฏธํ„ฐ ๋ฏธ๋„๋Ÿฌ์ ธ ๋‚ด๋ ค์˜จ๋‹ค. โ€‹ ๋‹ฌํŒฝ์ด๊ฐ€ ๋‚˜๋ฌด ์ •์ƒ์— ๋„๋‹ฌํ•˜๊ธฐ ์œ„ํ•ด์„  ๋ฉฐ์น ์ด ๊ฑธ๋ฆด๊นŒ์š”? #include int main () { int a, b, n, ans=0; scanf("%d %d %d", &a, &b ,&n); if(a 0){ ans++; n -= a; if(n

[๊ตฌ๋ฆ„][C++] 10ํšŒ E-PPER 2๋ฒˆ : OX ํ€ด์ฆˆ

https://level.goorm.io/exam/123589/10%ED%9A%8C-e-pper-ox-%ED%80%B4%EC%A6%88/quiz/1 ๊ตฌ๋ฆ„LEVEL ์ฝ”๋”ฉํ…Œ์ŠคํŠธ์—์„œ ๊ฐ€์žฅ ๋†’์€ ๋น„์ค‘์„ ์ฐจ์ง€ํ•˜๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œ๋ฅผ ์ œ์ž‘ํ•˜๊ณ  ํ’€์ดํ•  ์ˆ˜ ์žˆ๋Š” ์˜จ๋ผ์ธ ์ €์ง€ ์„œ๋น„์Šค์ž…๋‹ˆ๋‹ค. ๊ธฐ์—…์—์„œ ์„ ํ˜ธํ•˜๋Š” C, C++, ํŒŒ์ด์ฌ(Python), ์ž๋ฐ”(Java), ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ(Javascript) ์ด level.goorm.io #include #include using namespace std; int main() { char input[100]; cin >> input; int ans = 0; int tmp = 1; for(int i = 0; ; i++){ if(input[i] == 'O'){ ans += tmp; tmp+..

[BOJ G5][C++] ๋ฐฑ์ค€ 14891๋ฒˆ: ํ†ฑ๋‹ˆ๋ฐ”ํ€ด

https://www.acmicpc.net/problem/14891 14891๋ฒˆ: ํ†ฑ๋‹ˆ๋ฐ”ํ€ด ์ด 8๊ฐœ์˜ ํ†ฑ๋‹ˆ๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ํ†ฑ๋‹ˆ๋ฐ”ํ€ด 4๊ฐœ๊ฐ€ ์•„๋ž˜ ๊ทธ๋ฆผ๊ณผ ๊ฐ™์ด ์ผ๋ ฌ๋กœ ๋†“์—ฌ์ ธ ์žˆ๋‹ค. ๋˜, ํ†ฑ๋‹ˆ๋Š” N๊ทน ๋˜๋Š” S๊ทน ์ค‘ ํ•˜๋‚˜๋ฅผ ๋‚˜ํƒ€๋‚ด๊ณ  ์žˆ๋‹ค. ํ†ฑ๋‹ˆ๋ฐ”ํ€ด์—๋Š” ๋ฒˆํ˜ธ๊ฐ€ ๋งค๊ฒจ์ ธ ์žˆ๋Š”๋ฐ, ๊ฐ€์žฅ ์™ผ์ชฝ ํ†ฑ๋‹ˆ๋ฐ”ํ€ด www.acmicpc.net ๋ฌธ์ œ ์ด 8๊ฐœ์˜ ํ†ฑ๋‹ˆ๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ํ†ฑ๋‹ˆ๋ฐ”ํ€ด 4๊ฐœ๊ฐ€ ์•„๋ž˜ ๊ทธ๋ฆผ๊ณผ ๊ฐ™์ด ์ผ๋ ฌ๋กœ ๋†“์—ฌ์ ธ ์žˆ๋‹ค. ๋˜, ํ†ฑ๋‹ˆ๋Š” N๊ทน ๋˜๋Š” S๊ทน ์ค‘ ํ•˜๋‚˜๋ฅผ ๋‚˜ํƒ€๋‚ด๊ณ  ์žˆ๋‹ค. ํ†ฑ๋‹ˆ๋ฐ”ํ€ด์—๋Š” ๋ฒˆํ˜ธ๊ฐ€ ๋งค๊ฒจ์ ธ ์žˆ๋Š”๋ฐ, ๊ฐ€์žฅ ์™ผ์ชฝ ํ†ฑ๋‹ˆ๋ฐ”ํ€ด๊ฐ€ 1๋ฒˆ, ๊ทธ ์˜ค๋ฅธ์ชฝ์€ 2๋ฒˆ, ๊ทธ ์˜ค๋ฅธ์ชฝ์€ 3๋ฒˆ, ๊ฐ€์žฅ ์˜ค๋ฅธ์ชฝ ํ†ฑ๋‹ˆ๋ฐ”ํ€ด๋Š” 4๋ฒˆ์ด๋‹ค. ์ด๋•Œ, ํ†ฑ๋‹ˆ๋ฐ”ํ€ด๋ฅผ ์ด K๋ฒˆ ํšŒ์ „์‹œํ‚ค๋ ค๊ณ  ํ•œ๋‹ค. ํ†ฑ๋‹ˆ๋ฐ”ํ€ด์˜ ํšŒ์ „์€ ํ•œ ์นธ์„ ๊ธฐ์ค€์œผ๋กœ ํ•œ๋‹ค. ํšŒ์ „์€ ์‹œ๊ณ„ ๋ฐฉํ–ฅ๊ณผ ๋ฐ˜..

[BOJ][C++] ๋ฐฑ์ค€ 1074๋ฒˆ: Z

https://www.acmicpc.net/problem/1074 1074๋ฒˆ: Z ํ•œ์ˆ˜๋Š” ํฌ๊ธฐ๊ฐ€ 2N × 2N์ธ 2์ฐจ์› ๋ฐฐ์—ด์„ Z๋ชจ์–‘์œผ๋กœ ํƒ์ƒ‰ํ•˜๋ ค๊ณ  ํ•œ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, 2×2๋ฐฐ์—ด์„ ์™ผ์ชฝ ์œ„์นธ, ์˜ค๋ฅธ์ชฝ ์œ„์นธ, ์™ผ์ชฝ ์•„๋ž˜์นธ, ์˜ค๋ฅธ์ชฝ ์•„๋ž˜์นธ ์ˆœ์„œ๋Œ€๋กœ ๋ฐฉ๋ฌธํ•˜๋ฉด Z๋ชจ์–‘์ด๋‹ค. N > 1์ธ ๊ฒฝ์šฐ, ๋ฐฐ์—ด์„ www.acmicpc.net ๋ฌธ์ œ ํ•œ์ˆ˜๋Š” ํฌ๊ธฐ๊ฐ€ 2N × 2N์ธ 2์ฐจ์› ๋ฐฐ์—ด์„ Z๋ชจ์–‘์œผ๋กœ ํƒ์ƒ‰ํ•˜๋ ค๊ณ  ํ•œ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, 2×2๋ฐฐ์—ด์„ ์™ผ์ชฝ ์œ„์นธ, ์˜ค๋ฅธ์ชฝ ์œ„์นธ, ์™ผ์ชฝ ์•„๋ž˜์นธ, ์˜ค๋ฅธ์ชฝ ์•„๋ž˜์นธ ์ˆœ์„œ๋Œ€๋กœ ๋ฐฉ๋ฌธํ•˜๋ฉด Z๋ชจ์–‘์ด๋‹ค. N > 1์ธ ๊ฒฝ์šฐ, ๋ฐฐ์—ด์„ ํฌ๊ธฐ๊ฐ€ 2N-1 × 2N-1๋กœ 4๋“ฑ๋ถ„ ํ•œ ํ›„์— ์žฌ๊ท€์ ์œผ๋กœ ์ˆœ์„œ๋Œ€๋กœ ๋ฐฉ๋ฌธํ•œ๋‹ค. ๋‹ค์Œ ์˜ˆ๋Š” 22 × 22 ํฌ๊ธฐ์˜ ๋ฐฐ์—ด์„ ๋ฐฉ๋ฌธํ•œ ์ˆœ์„œ์ด๋‹ค. N์ด ์ฃผ์–ด์กŒ์„ ๋•Œ, rํ–‰ c์—ด์„ ๋ช‡ ๋ฒˆ์งธ..

[BOJ][C++] ๋ฐฑ์ค€ 13305๋ฒˆ: ์ฃผ์œ ์†Œ

https://www.acmicpc.net/problem/13305 13305๋ฒˆ: ์ฃผ์œ ์†Œ ํ‘œ์ค€ ์ž…๋ ฅ์œผ๋กœ ๋‹ค์Œ ์ •๋ณด๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. ์ฒซ ๋ฒˆ์งธ ์ค„์—๋Š” ๋„์‹œ์˜ ๊ฐœ์ˆ˜๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ์ •์ˆ˜ N(2 ≤ N ≤ 100,000)์ด ์ฃผ์–ด์ง„๋‹ค. ๋‹ค์Œ ์ค„์—๋Š” ์ธ์ ‘ํ•œ ๋‘ ๋„์‹œ๋ฅผ ์—ฐ๊ฒฐํ•˜๋Š” ๋„๋กœ์˜ ๊ธธ์ด๊ฐ€ ์ œ์ผ ์™ผ์ชฝ ๋„๋กœ๋ถ€ํ„ฐ N-1 www.acmicpc.net ๋ฌธ์ œ ์–ด๋–ค ๋‚˜๋ผ์— N๊ฐœ์˜ ๋„์‹œ๊ฐ€ ์žˆ๋‹ค. ์ด ๋„์‹œ๋“ค์€ ์ผ์ง์„  ๋„๋กœ ์œ„์— ์žˆ๋‹ค. ํŽธ์˜์ƒ ์ผ์ง์„ ์„ ์ˆ˜ํ‰ ๋ฐฉํ–ฅ์œผ๋กœ ๋‘์ž. ์ œ์ผ ์™ผ์ชฝ์˜ ๋„์‹œ์—์„œ ์ œ์ผ ์˜ค๋ฅธ์ชฝ์˜ ๋„์‹œ๋กœ ์ž๋™์ฐจ๋ฅผ ์ด์šฉํ•˜์—ฌ ์ด๋™ํ•˜๋ ค๊ณ  ํ•œ๋‹ค. ์ธ์ ‘ํ•œ ๋‘ ๋„์‹œ ์‚ฌ์ด์˜ ๋„๋กœ๋“ค์€ ์„œ๋กœ ๊ธธ์ด๊ฐ€ ๋‹ค๋ฅผ ์ˆ˜ ์žˆ๋‹ค. ๋„๋กœ ๊ธธ์ด์˜ ๋‹จ์œ„๋Š” km๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค. ์ฒ˜์Œ ์ถœ๋ฐœํ•  ๋•Œ ์ž๋™์ฐจ์—๋Š” ๊ธฐ๋ฆ„์ด ์—†์–ด์„œ ์ฃผ์œ ์†Œ์—์„œ ๊ธฐ๋ฆ„์„ ๋„ฃ๊ณ  ์ถœ๋ฐœํ•˜์—ฌ์•ผ ํ•œ๋‹ค. ๊ธฐ๋ฆ„ํ†ต์˜ ํฌ..

[BOJ][C++] 13458๋ฒˆ: ์‹œํ—˜ ๊ฐ๋…

https://www.acmicpc.net/problem/13458 13458๋ฒˆ: ์‹œํ—˜ ๊ฐ๋… ์ฒซ์งธ ์ค„์— ์‹œํ—˜์žฅ์˜ ๊ฐœ์ˆ˜ N(1 ≤ N ≤ 1,000,000)์ด ์ฃผ์–ด์ง„๋‹ค. ๋‘˜์งธ ์ค„์—๋Š” ๊ฐ ์‹œํ—˜์žฅ์— ์žˆ๋Š” ์‘์‹œ์ž์˜ ์ˆ˜ Ai (1 ≤ Ai ≤ 1,000,000)๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. ์…‹์งธ ์ค„์—๋Š” B์™€ C๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. (1 ≤ B, C ≤ 1,000,000) www.acmicpc.net ๋ฌธ์ œ ์ด N๊ฐœ์˜ ์‹œํ—˜์žฅ์ด ์žˆ๊ณ , ๊ฐ๊ฐ์˜ ์‹œํ—˜์žฅ๋งˆ๋‹ค ์‘์‹œ์ž๋“ค์ด ์žˆ๋‹ค. i๋ฒˆ ์‹œํ—˜์žฅ์— ์žˆ๋Š” ์‘์‹œ์ž์˜ ์ˆ˜๋Š” Ai๋ช…์ด๋‹ค. ๊ฐ๋…๊ด€์€ ์ด๊ฐ๋…๊ด€๊ณผ ๋ถ€๊ฐ๋…๊ด€์œผ๋กœ ๋‘ ์ข…๋ฅ˜๊ฐ€ ์žˆ๋‹ค. ์ด๊ฐ๋…๊ด€์€ ํ•œ ์‹œํ—˜์žฅ์—์„œ ๊ฐ์‹œํ•  ์ˆ˜ ์žˆ๋Š” ์‘์‹œ์ž์˜ ์ˆ˜๊ฐ€ B๋ช…์ด๊ณ , ๋ถ€๊ฐ๋…๊ด€์€ ํ•œ ์‹œํ—˜์žฅ์—์„œ ๊ฐ์‹œํ•  ์ˆ˜ ์žˆ๋Š” ์‘์‹œ์ž์˜ ์ˆ˜๊ฐ€ C๋ช…์ด๋‹ค. ๊ฐ๊ฐ์˜ ์‹œํ—˜์žฅ์— ์ด๊ฐ๋…๊ด€์€ ์˜ค์ง 1๋ช…๋งŒ ์žˆ์–ด์•ผ..

[BOJ][C++] ๋ฐฑ์ค€ 1259๋ฒˆ: ํŒฐ๋ฆฐ๋“œ๋กฌ์ˆ˜

https://www.acmicpc.net/problem/1259 1259๋ฒˆ: ํŒฐ๋ฆฐ๋“œ๋กฌ์ˆ˜ ์ž…๋ ฅ์€ ์—ฌ๋Ÿฌ ๊ฐœ์˜ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ์œผ๋ฉฐ, ๊ฐ ์ค„๋งˆ๋‹ค 1 ์ด์ƒ 99999 ์ดํ•˜์˜ ์ •์ˆ˜๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. ์ž…๋ ฅ์˜ ๋งˆ์ง€๋ง‰ ์ค„์—๋Š” 0์ด ์ฃผ์–ด์ง€๋ฉฐ, ์ด ์ค„์€ ๋ฌธ์ œ์— ํฌํ•จ๋˜์ง€ ์•Š๋Š”๋‹ค. www.acmicpc.net ๋ฌธ์ œ ์–ด๋–ค ๋‹จ์–ด๋ฅผ ๋’ค์—์„œ๋ถ€ํ„ฐ ์ฝ์–ด๋„ ๋˜‘๊ฐ™๋‹ค๋ฉด ๊ทธ ๋‹จ์–ด๋ฅผ ํŒฐ๋ฆฐ๋“œ๋กฌ์ด๋ผ๊ณ  ํ•œ๋‹ค. 'radar', 'sees'๋Š” ํŒฐ๋ฆฐ๋“œ๋กฌ์ด๋‹ค. ์ˆ˜๋„ ํŒฐ๋ฆฐ๋“œ๋กฌ์œผ๋กœ ์ทจ๊ธ‰ํ•  ์ˆ˜ ์žˆ๋‹ค. ์ˆ˜์˜ ์ˆซ์ž๋“ค์„ ๋’ค์—์„œ๋ถ€ํ„ฐ ์ฝ์–ด๋„ ๊ฐ™๋‹ค๋ฉด ๊ทธ ์ˆ˜๋Š” ํŒฐ๋ฆฐ๋“œ๋กฌ์ˆ˜๋‹ค. 121, 12421 ๋“ฑ์€ ํŒฐ๋ฆฐ๋“œ๋กฌ์ˆ˜๋‹ค. 123, 1231์€ ๋’ค์—์„œ๋ถ€ํ„ฐ ์ฝ์œผ๋ฉด ๋‹ค๋ฅด๋ฏ€๋กœ ํŒฐ๋ฆฐ๋“œ๋กฌ์ˆ˜๊ฐ€ ์•„๋‹ˆ๋‹ค. ๋˜ํ•œ 10๋„ ํŒฐ๋ฆฐ๋“œ๋กฌ์ˆ˜๊ฐ€ ์•„๋‹Œ๋ฐ, ์•ž์— ๋ฌด์˜๋ฏธํ•œ 0์ด ์˜ฌ ์ˆ˜ ์žˆ๋‹ค๋ฉด 010์ด ๋˜์–ด ํŒฐ๋ฆฐ๋“œ..

[C++][BOJ] ๋ฐฑ์ค€ 15366๋ฒˆ: Olivander

https://www.acmicpc.net/problem/15366 15366๋ฒˆ: Olivander Harry Potter has damaged his magic wand in a fight with Lord Voldemort. He has decided to get a new wand in Olivander's wand shop. On the floor of the shop, he saw N wands and N wand boxes. The lengths of the wands are, respectively, X1, X2, ...Xn, and th www.acmicpc.net ๋ฌธ์ œ Harry Potter has damaged his magic wand in a fight with Lord Voldem..

[C++][BOJ] ๋ฐฑ์ค€ 6997๋ฒˆ: Guessing Game 1

https://www.acmicpc.net/problem/6997 6997๋ฒˆ: Guessing Game I After a long trek through treacherous mountains, Bilbo and the dwarfs have arrived at the West Gate of the mines of Puzzlia, constructed by a mathematically inclined Dwarf King. The gate is of course not open (nothing can be that easy for our heroes), and www.acmicpc.net ๋ฌธ์ œ After a long trek through treacherous mountains, Bilbo and the ..

๋ฐ˜์‘ํ˜•