-
알고리즘 & 자료구조 스터디(10조) 7일차알고리즘 2023. 5. 29. 20:36
Q. 2231 분해
num = int(input()) result = 0 for i in range(num): list_1 = list(map(int, str(i))) # [1, 9, 8] sum_num = sum(list_1) # 18 if num == i + sum_num: # i = 198 # num = 216 이랑 198 + 18 이 같으면 result 에 저장 하고 반복문 종료 result = i break print(result)
Q. 2798 블랙
n,m = map(int,input().split()) data = list(map(int,input().split())) data.sort() munyeol = [] for i in data: for j in data: if i == j: continue for k in data: if i == k: continue if j == k: continue sum_num = i + j + k if sum_num <= m: munyeol.append(sum_num) else: pass print(max(munyeol))
Q. 2776 암기왕
set 함수의 개념을 알아야하는 게 중요함 set 은 중복제거
t = int(input()) for i in range(t): b1 = int(input()) book1 = set(map(int,input().split())) b2 = int(input()) book2 = map(int,input().split()) for j in book2: if j in book1: print(1) else: print(0)
무난히 풀었다 셋 다
Q. 2776 다리 놓기
수학공식 모르면 못푸는 문제에 1시간을 쏟아부어 놓으니깐 머리가 너무 아프다 진짜로!!!!
import math t = int(input()) for i in range(t): count = 1 west, east = map(int, input().split()) print(int(math.factorial(east) / (math.factorial(west)*(math.factorial(east-west)))))
'알고리즘' 카테고리의 다른 글
알고리즘 Day-1 (0) 2023.06.16 알고리즘 & 자료구조 스터디(10조) 8일차 (0) 2023.05.30 알고리즘 & 자료구조 스터디(10조) 6일차 (0) 2023.05.27 알고리즘 & 자료구조 스터디(10조) 5일차 (0) 2023.05.26 알고리즘 & 자료구조 스터디(10조) 4일차 (1) 2023.05.25