๋์ ์ฝ๋ # ์ฐ -> ํ -> ์ข -> ์ 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 ํ๊ณ ๋ง์ง๋ง์ ์ถ๋ ฅํด๋ ๋๊ฒ ๋ค.
๋์ ์ฝ๋ t = int(input()) for tc in range(1,t+1): n = int(input()) lt = n//2 rt = n//2 result = 0 for _ in range(n//2): arr = list(map(int,input())) result += sum(arr[lt:rt+1]) lt -= 1 rt += 1 for _ in range(n//2,n): arr = list(map(int,input())) result += sum(arr[lt:rt+1]) lt += 1 rt -= 1 print("#"+str(tc) , result ) ์ฝ๋๊ฐ ๋๋ฌด ์ง์ ๋ถํด์ ๋ค์ ํ์๋ค. ์์ ์ฝ๋ t = int(input()) for tc in range(1,t+1): n = int(input()..
๋์ ์ฝ๋ for _ in range(10): t = int(input()) arr = [] for _ in range(100): tmp = list(map(int,input().split())) arr.append(tmp) large = 0 c = [] d = [] for i in range(100): if sum(arr[i]) > large : large = sum(arr[i]) b = [j[i] for j in arr] if sum(b) > large : large = sum(b) c.append(arr[i][i]) d.append(arr[i][99-i]) result = max(large,sum(c),sum(d)) print("#"+str(t) , result) ํ, ์ด, ๋๊ฐ์ 1, ๋๊ฐ์ 2 ๊ฐ๊ฐ..
๋์ ์ฝ๋ for t in range(1, 11): n,s = input().split() n = int(n) + 2 arr = list(s) flag = True while flag: n -= 2 for i in range(n-1): if arr[i] == arr[i+1]: arr.pop(i) arr.pop(i) break else: flag = False print("#"+str(t) ," ", *arr , sep="") ๋ฐฐ์ด์์ ๋ฐ๋ณต๋ฌธ์ ์ํํ์ฌ ๋ค์ ์ธ๋ฑ์ค์ ๊ฐ์ด ๊ฐ์ผ๋ฉด ๋๋ค ์๊ฑฐ pop() ๋ฐ๋ณต๋ฌธ์ ๊ธธ์ด๋ ๊ฐ์์ํด n -= 2 ๋ฐฐ์ด์์ ๋์ด์ ์๊ฑฐํ ๋ฒํธ ์์ด ์์ผ๋ฉด while ๋ฐ๋ณต๋ฌธ์ ์ข ๋ฃ ์ํค๊ธฐ ์ํด flag ๋ณ์๋ฅผ ์ด์ฉ for-else ๋ฌธ for i in range(5): print(i, ..
๋์ ์ฝ๋ T = int(input()) for t in range(1, T + 1): arr = list(map(int,input().split())) cnt = [0]*101 result = 0 for x in arr: cnt[x] += 1 for i in range(len(cnt)): if cnt[i] ==1 or cnt[i] ==3 : result = i print("#"+str(t) , result) ์ ๋ ฅ๋ฐ์ ์๋ฅผ ์นด์ดํ ํ๋ค. ์ง์ง ๋ฉ์ฒญํ๊ฒ ํ์๋ค. ์ฝ๋ ์์ T = int(input()) for t in range(1, T + 1): arr = list(map(int,input().split())) arr.sort() result = 0 if arr[0] == arr[1]: result = a..