알고리즘/알고리즘_swea 41

[Python][SWEA] 3809. 화섭이의 정수 나열 D3

🗒️ 파이썬 코드 풀이T = int(input())for tc in range(1, T+1): N = int(input()) value = "" while True : value += ''.join(list(input().split())) if len(value) == N : break n = 0 while True: if str(n) not in value: break n += 1 print(f"#{tc} {n}") 1. 우선 입력구조가 다른 문제와 다르다. (10개의 입력이 넘어가면 엔터가 있음)이런 경우  반복문을 돌려서 해당값을 받아줘야한다.  N의 개수를 입력 받기 때문에,  value의 크기..

[Python][SWEA] 4698. 테네스의 특별한 소수 D3

SW Expert AcademySW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!swexpertacademy.com🗒️ 파이썬 코드 풀이lst = [i for i in range(1000001)] # 에라토스테네스 리스트 만들기for i in range(2,1000001) : # 2부터 시작해야 함 for j in range(i,1000001,i): # 각 수의 배수를 0으로 변환 if lst[j] == i : continue # i=j (해당값)은 변환 X lst[j] = 0T = int(input())for test_case in range(1, T + 1): D,A,B = map(int,input().split()) cnt = 0 ..

[Python][SWEA] 4751. 다솔이의 다이아몬드 장식 D3

SW Expert AcademySW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!swexpertacademy.com 🗒️ 파이썬 코드 풀이T = int(input())for tc in range(1,T+1): dasol = list(input()) lst = [["."] * 5 for _ in range(5)] # 다이아 몬드 형태로 바꿔주기 shap = [(0,2),(1,1),(1,3),(2,0),(2,4),(3,1),(3,3),(4,2)] for i,j in shap: lst[i][j] = "#" chaged_lst = [lst[i].copy() for i in range(5)] # 얕은 복사 # 기존 리스트 변형 (맨 뒤 요..

[Python][SWEA] 9480. 민정이와 광직이의 알파벳 공부 D3

SW Expert AcademySW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!swexpertacademy.com 🗒️ 파이썬 코드 풀이def Alphabet_combination(n,lst_union): global ans if n == N : if lst_union == alphabet: ans+=1 return Alphabet_combination(n+1,lst_union|set(lst[n])) Alphabet_combination(n+1,lst_union)T = int(input())for tc in range(1,T+1): N = int(input()) lst = [set(input().str..

[Python][SWEA] 14413. 격자판 칠하기 D3

SW Expert AcademySW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!swexpertacademy.com 🗒️ 파이썬 코드 풀이def grid(type1,type2) : for i in range(N): for j in range(M) : if lst[i][j] == '?' : continue # "?"인 값은 제외 if (i+j)%2 == 0 : # i+j가 짝수인 경우 if lst[i][j] != type1: # 각 case와 일치하지 않는 경우 return False else : if lst[i][j]..

[Python][SWEA] 6485. 삼성시의 버스 노선 D3

SW Expert AcademySW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!swexpertacademy.com🗒️ 파이썬 코드 풀이T = int(input())for tc in range(1,T+1) : N = int(input()) lst = [0]*5001 for _ in range(N) : A,B = map(int,input().split()) for i in range(A,B+1) : lst[i] += 1 ans = [] P = int(input()) for _ in range(P) : P_num = int(input()) ans.append(lst[P_num]) ..

[Python][SWEA] 7510. 상원이의 연속 합 D3

SW Expert AcademySW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!swexpertacademy.com🗒️ 파이썬 코드 풀이T = int(input())for tc in range(1,T+1) : N = int(input()) cnt = 1 sum = 0 i = 2 # 연속이 되기 위한 최소 수 while True : sum += i-1 if (N-sum)  1. 해당 규칙이 있는데, 이 규칙을 코드로 풀면 된다.2개 연속  :  n + (n+1) = N   => (N-1) / 2 = n3개 연속  :  n + (n+1) + (n+2) = N    => (N - (1+2)) / 3 = n4개 연속  :  n + ..

[Python][SWEA] 4299. 태혁이의 사랑은 타이밍 D3

SW Expert AcademySW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!swexpertacademy.com🗒️ 파이썬 코드 풀이T = int(input())for test_case in range(1, T + 1): D,H,M = map(int,input().split()) date_time = 11*60 + 11 wind_time = ((D-11)*24*60) + (H*60) + M # 날 - 시 - 분 (분으로 변환) ans = wind_time-date_time if ans  1. D의 범위가 11~14까지로 정해져있기 때문에, 11일 0시 0분 ~ "입력받은 시간" 까지를 분으로 전환해준다.(만일 D의 범위가 이전 달을 넘어가면, 다른..

[Python][SWEA] 14178. 1차원 정원 D3

SW Expert AcademySW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!swexpertacademy.com🗒️ 파이썬 코드 풀이T = int(input())for test_case in range(1, T + 1): N,D = map(int,input().split()) min_bunmugi = N // (2*D+1) if N % (2*D+1) == 0 : print(f"#{test_case} {min_bunmugi}") else: print(f"#{test_case} {min_bunmugi+1}") 1. 문제에 수직 정원이라 되어있는데, 수평으로 해도 큰 문제가 없다. 2. 여기에서 가장 최적의 순간은 분무기가 겹치지 않고 ..

[Python][SWEA] 1961. 숫자 배열 회전

SW Expert AcademySW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!swexpertacademy.com🗒️ 파이썬 코드 풀이def rotation(lst,N): tmp_lst = [] for j in range(N): tmp = [] for i in range(N-1,-1,-1): tmp.append(str(lst[i][j])) tmp_lst.append(tmp) return tmp_lstT = int(input())for test_case in range(1, T + 1): N = int(input()) lst_origin = [list(map(int, input().split())..