Algorithm/SWEA

Algorithm/SWEA

[SWEA - D3] 1230. ์•”ํ˜ธ๋ฌธ3

๋‚˜์˜ ์ฝ”๋“œ for t in range(1, 11): N = int(input()) # ์ฒซ ๋ฒˆ์งธ ์ค„ : ์›๋ณธ ์•”ํ˜ธ๋ฌธ์˜ ๊ธธ์ด N arr = list(map(int,input().split())) # ๋‘ ๋ฒˆ์งธ ์ค„ : ์›๋ณธ ์•”ํ˜ธ๋ฌธ cmd = int(input()) # ์„ธ ๋ฒˆ์งธ ์ค„ : ๋ช…๋ น์–ด์˜ ๊ฐœ์ˆ˜ cmd_arr = list(input().split()) # ๋„ค ๋ฒˆ์งธ ์ค„ : ๋ช…๋ น์–ด for i in range(len(cmd_arr)): if cmd_arr[i] == 'A' : cnt = int(cmd_arr[i+1]) for j in range(cnt): tmp = int(cmd_arr[i+2+j]) arr.append(tmp) if cmd_arr[i] == 'I': idx = int(cmd_arr[i+1]) cn..

Algorithm/SWEA

[SWEA - D3] 1213. String

์ฃผ์–ด์ง€๋Š” ๋ฌธ์ž์—ด์—์„œ ํŠน์ •ํ•œ ๋ฌธ์ž์—ด์˜ ๊ฐœ์ˆ˜๋ฅผ ๋ฐ˜ํ™˜ํ•˜๊ธฐ๊ธฐ Starteatingwellwiththeseeighttipsforhealthyeating,whichcoverthebasicsofahealthydietandgoodnutrition. ์œ„ ๋ฌธ์žฅ์—์„œ ti ๋ฅผ ๊ฒ€์ƒ‰ํ•˜๋ฉด, ๋‹ต์€ 4์ด๋‹ค. ๋‚˜์˜ ์ฝ”๋“œ for _ in range(1, 11): t = int(input()) s1 = input() s2 = input() s1L = len(s1) s2L = len(s2) cnt = 0 for i in range(s2L-s1L+1): if s2[i:s1L+i] == s1: cnt += 1 print("#"+str(t) , cnt ) ํŒŒ์ด์ฌ์—๋Š” count ํ•จ์ˆ˜๊ฐ€ ์žˆ๋‹ค. ์ƒ๊ฐ ์•ˆ๋‚˜์„œ ๋ฌธ์ž์—ด ์Šฌ๋ผ์ด์‹ฑํ•ด์„œ ๋ฐ˜๋ณต๋ฌธ๋Œ๋ฆฌ๊ณ  ๋น„๊ตํ•ด์„œ ..

Algorithm/SWEA

[SWEA - D3] 1225. ์•”ํ˜ธ์ƒ์„ฑ๊ธฐ

๋‚˜์˜ ์ฝ”๋“œ from collections import deque for _ in range(1, 11): t = int(input()) arr = list(map(int,input().split())) deq = deque(arr) while 0 not in deq: for i in range(1,6): tmp = deq.popleft() if tmp-i

Algorithm/SWEA

[SWEA - D3] 1216. ํšŒ๋ฌธ2

๊ฐ€์žฅ ๊ธด ํšŒ๋ฌธ์˜ ๊ธธ์ด๋ฅผ ๊ตฌํ•˜๋Š” ๋ฌธ์ œ ๋‚˜์˜ ์ฝ”๋“œ for _ in range(10): t = int(input()) arr = [] result = 0 for _ in range(100): arr.append(input()) for i in range(100): b = [x[i] for x in arr] for j in range(100): for length in range(1,101): if j+length > 100: break tmp1 = arr[i][j:j+length] tmp2 = b[j:j+length] if tmp1 == tmp1[::-1] and length > result: result = length if tmp2 == tmp2[::-1] and length > result: result..

Algorithm/SWEA

[SWEA - D3] 1215. ํšŒ๋ฌธ1

๋‚˜์˜ ์ฝ”๋“œ for t in range(1,11): length = int(input()) arr = [] cnt = 0 for _ in range(8): arr.append(input()) for j in range(8): b = [i[j] for i in arr] for i in range(0,9-length): if list(arr[j][i:length+i]) == list(reversed(arr[j][i:length+i])): cnt += 1 if list(b[i:length+i]) == list(reversed(b[i:length+i])): cnt += 1 print("#"+str(t) , cnt) 2์ฐจ์› ๋ฐฐ์—ด์—์„œ ํ–‰ ์ถœ๋ ฅํ•˜๊ธฐ a = [ [0, 1], [2, 3], [4, 5], [6, 7], [..

Algorithm/SWEA

[SWEA - D3] 1217. ๊ฑฐ๋“ญ ์ œ๊ณฑ

๋‚˜์˜ ์ฝ”๋“œ def x(a,b): if b==0: return 1 else: return a*x(a,b-1) for _ in range(1, 11): t = int(input()) a,b = map(int,input().split()) print("#"+str(t) , x(a,b) ) ์žฌ๊ท€๋ฅผ ์ด์šฉํ•ด์„œ ๊ฑฐ๋“ญ์ œ๊ณฑ์„ ๊ณ„์‚ฐ for _ in range(1, 11): t = int(input()) a,b = map(int,input().split()) print("#"+str(t) , a**b ) ์žฌ๊ท€๋ฅผ ์ด์šฉํ•˜์ง€ ์•Š๋Š”๋‹ค๋ฉด ์—„์ฒญ ๊ฐ„๋‹จํ•œ ๋ฌธ์ œ

Algorithm/SWEA

[SWEA - D3] 4406. ๋ชจ์Œ์ด ๋ณด์ด์ง€ ์•Š๋Š” ์‚ฌ๋žŒ

๋‚˜์˜ ์ฝ”๋“œ T = int(input()) # ์—ฌ๋Ÿฌ๊ฐœ์˜ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๊ฐ€ ์ฃผ์–ด์ง€๋ฏ€๋กœ, ๊ฐ๊ฐ์„ ์ฒ˜๋ฆฌํ•ฉ๋‹ˆ๋‹ค. arr = [ "a" , "e" , "i" , "o" , "u" ] for t in range(1, T + 1): s = input() result = '' for x in s: if x not in arr: result += x print("#"+str(t) , result ) replace() ํ•จ์ˆ˜ ์ƒ๊ฐ ์•ˆ๋‚˜์„œ ๊ทธ๋ƒฅ ๋ฌธ์ž์—ด ๋”ํ•˜๊ธฐ๋กœ ํ’€์—ˆ๋‹ค. replace() ํ•จ์ˆ˜ a = input() for i in ["a","e","i","o","u"]: a=a.replace(i,"")

Algorithm/SWEA

[SWEA - D3] 1206. View

๋‚˜์˜ ์ฝ”๋“œ for t in range(1,11): n = int(input()) arr = list(map(int,input().split())) result = 0 for i in range(2,n-2): mid = arr[i] left = max(arr[i-1],arr[i-2]) right = max(arr[i+1],arr[i+2]) if mid > left and mid > right : result += mid - max(left,right) print("#"+str(t) , result ) ์™ผ์ชฝ, ์˜ค๋ฅธ์ชฝ, ๊ฐ๊ฐ ๋น„๊ตํ–ˆ๋Š”๋ฐ ๊ทธ๋Ÿดํ•„์š”๊ฐ€ ์—†์—ˆ๋„ค ์–ด์ฐจํ”ผ ๊ธฐ์ค€์ด ์ œ์ผ ๋†’์•„์•ผ๋˜๋‹ˆ๊นŒ ใ…‡ใ…‡ ๋‹ค๋ฅธ ์‚ฌ๋žŒ ํ’€์ด for T in range(1, 11): n=int(input()) data=list(map(int, i..

hello_u
'Algorithm/SWEA' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก (2 Page)