SWLUG/๋ฐฑ์ค€ BEAKJOON 39

[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์žฅ์˜ ์นด๋“œ ์ค‘์—..

[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..

[BAEKJOON/ ๋ฐฑ์ค€] 1520๋ฒˆ: ๋‚ด๋ฆฌ๋ง‰ ๊ธธ (Python)

[1] ์ •๋‹ต ์ฝ”๋“œ import sys sys.setrecursionlimit(10**5) input=sys.stdin.readline M,N=map(int, input().split()) plan=[list(map(int, input().split())) for _ in range(M)] route=[[-1]*N for _ in range(M)] dx=[1,-1,0,0] dy=[0,0,1,-1] def dfs(start): x,y=start if x==M-1 and y==N-1: return 1 if route[x][y]!=-1: return route[x][y] route[x][y]=0 for i in range(4): nx=x+dx[i] ny=y+dy[i] if nx=M or ny=N: continu..

[BEAKJOON/ ๋ฐฑ์ค€] 2629๋ฒˆ: ์–‘ํŒ”์ €์šธ (Python)

[1] ์ •๋‹ต ์ฝ”๋“œ import sys n = int(sys.stdin.readline()) weight = list(map(int, sys.stdin.readline().split())) m = int(sys.stdin.readline()) check = list(map(int, sys.stdin.readline().split())) possible = [] ans = [[0 for _ in range(15001)] for __ in range(n + 1)] def scale(weight, n, now, left, right): new = abs(left - right) if new not in possible: possible.append(new) if now == n: return 0 if ans[n..