분류 전체보기
-
알고리즘 & 자료구조 스터디(10조) 6일차알고리즘 2023. 5. 27. 21:16
Q. 1037 약수 구하기 약수를 구할 때는 제일 큰수 * 제일 작은수가 포인트입니다. n = int(input()) t = list(map(int, input().split())) t.sort() if len(t) % 2 == 0: answer = t[0] * t[-1] else: num = len(t) // 2 answer = t[num] print(answer) Q. 1874 스택수열 누군가 그랬다 이중반복문은 일단 틀릴 가능성이 높다고 근데 이거 왜 이중반복문이냐... while 반복문에서 or 하나 못생각해내서 힘들어죽을 뻔 했다 T = int(input()) stacknumList = [] stack = [] checkList = [] for _ in range(T): stacknumList...
-
알고리즘 & 자료구조 스터디(10조) 5일차알고리즘 2023. 5. 26. 21:37
Q. 4949 균형 잡힌 세상 멘붕입니다.. 머리가 많이 아파요 거의 다 풀 뻔 했는데 못해서 너무 힘들어요 살려주세요.. Q. 1978 소수 찾기 n = int(input()) arr = list(map(int,input().split())) count = len(arr) for i in arr: if i == 1: count -= 1 elif i == 2: continue for j in range(2,i): if i % j == 0: count -= 1 break print(count) Q. 10866 덱 from collections import deque import sys n = int(input()) q= deque() for i in range(n): data = list(sys.stdin..
-
알고리즘 & 자료구조 스터디(10조) 4일차알고리즘 2023. 5. 25. 20:59
Q. 14916 while문 안의 n 에 주목해야 할 점이 있었으며 지역변수 전역변수 개념과 헷갈린 부분도 있어서 개념이 약한 부분을 알 수 있었다 그리디문제의 대표적 유형이라고 생각하고 기억해 놓으면 좋을 것 같다 n = int(input()) coin = [5, 2] count = 0 while n % coin[0] != 0: n -= coin[1] count += 1 if n < 0: break if n < 0: print(-1) else: count = count + n // coin[0] print(count) Q. 1436 영화감독 생각하고 풀어보니 꽤나 쉬운문제로 in 을 통해서 판별하니깐 잘 나옴 n = int(input()) i = 0 list_2 = [] while len(list_2)..
-
알고리즘 & 자료구조 스터디(10조) 3일차알고리즘 2023. 5. 24. 21:40
Q.10828 스택 Q.10773 제로 Q.18258 큐 강의에서 관련된 내용이 나와서 수월하게 문제를 풀 수 있었다. 아쉽게도 문제 푼 코드를 삭제 해버려서 다음에 다시 한번 풀고 결과를 남겨봐야지 Q.1929 소수구하기 소수 구하는 문제 관련되서 힘이든다... 이해력이 좀 딸리는지 구현이 어려워서 다음에 답지를 보고 외워야겠다. import sys a, b = map(int, sys.stdin.readline().split()) def asdf(n): for i in range(2, n): if n % i == 0: return False return True for i in range(a, b): if asdf(i) == True: print(i) 자료구조&알고리즘 1강 (완료)