๋์ ์ฝ๋ # ์ฐ -> ํ -> ์ข -> ์ dr = [0, 1, 0, -1] dc = [1, 0, -1, 0] T = int(input()) for t in range(1,T+1): n = int(input()) arr = [[0]*n for _ in range(n)] r = 0 c = 0 dist = 0 for i in range(1,n*n+1): arr[r][c] = i r += dr[dist] c += dc[dist] if r = n or c >= n or arr[r][c] != 0 : r -= dr[dist] c -= dc[dist] dist = (dist +1) % 4 r += dr[dist] c += dc[dist] print("#"+str(t)) for x..
์ ๋ต์จ ๋์ ๋ฌธ์ ํ์ด๋ค 3314. ๋ณด์ถฉํ์ต๊ณผ ํ๊ท T = int(input()) for t in range(1, T + 1): arr = list(map(int,input().split())) res = [] for x in arr: if x < 40 : res.append(40) else: res.append(x) print("#"+str(t) , sum(res)//5 ) 9700. USB ๊ฝ๊ธฐ์ ๋ฏธ์คํฐ๋ฆฌ T = int(input()) for t in range(1,T+1): p,q = map(float,input().split()) s1 = (1-p) * q s2 = p*(1-q)*q if s1 < s2: res = "YES" else: res = "NO" print("#"+str(t) , res ..
๋์ ์ฝ๋ def DFS(L,score,kcal): global res if kcal > k: return if score > res: res = score if L == n: return s,c = arr[L] DFS(L+1,score+s, kcal+c) DFS(L+1,score,kcal) T = int(input()) for t in range(1,T+1): n,k = map(int,input().split()) arr = [] res = 0 for _ in range(n): a,b = map(int,input().split()) arr.append((a,b)) DFS(0,0,0) print("#"+str(t) , res ) DFS ๋ฅผ ์ด์ฉํ ํ์ด ํ๋ฒ๊ฑฐ ์ฌ๋ฃ์(n), ๋์ง ๋ง์์ผ ํ๋ ์นผ๋ก๋ฆฌ์(k)..
๋์ ์ฝ๋ T = int(input()) for t in range(1,T+1): n,k = map(int,input().split()) arr = list(map(int,input().split())) print("#"+str(t) , end=" ") for i in range(1,n+1): if i not in arr: print(i , end=" ") print() ๊ณผ์ ๋ฅผ ์ ์ถํ์ง ์์ ์ฌ๋์ ๋ฆฌ์คํธ๋ฅผ ๋ง๋ค์ด์ append ํ๊ณ ๋ง์ง๋ง์ ์ถ๋ ฅํด๋ ๋๊ฒ ๋ค.