본문 바로가기

전체 글71

조건문 연습 - 2480 그렇게 맘에 들지는 않는 풀이.. 더 좋은 방법이 있을듯 하다## 2480 주사위 세개x, y, z = input().split()x = int(x)y = int(y)z = int(z)if x == y and y == z: ## 같은 눈 3개 나올 때 prize = x*1000 + 10000elif x == y or y == z or x == z: ## 같은 눈 2개 나올 때 lst = [] lst.append(x) lst.append(y) lst.append(z) cnt = {} for i in lst: if i in cnt : cnt[i] = cnt[i] + 1 cnt_fin = i else: cnt[i] = 1 prize = c.. 2024. 6. 21. 19:13
그림으로 개념을 이해하는 알고리즘 - Ch 04 CH 04. 퀵 정렬  - 분할 정복 전략① 여러 작은 단계로 분할② 작은 단계 해결 # 분할 정복def sum(arr): total = 0 for x in arr: total += x return totalprint(sum([1, 2, 3, 4])) ** 유클리드 호제법 : 최대공약수 찾기 알고리즘https://www.khanacademy.org/computing/computer-science/cryptography/modarithmetic/a/the-euclidean-algorithm  - 퀵 정렬 : 기준 원소를 기준으로 모든 원소를 기준 원소보다 큰지 작은지 분류 > 하위 배열이 정렬된 경우 : 왼쪽 배열 + 기준 원소 + 오른쪽 배열 > 하위 배열이 정렬되지 않은 경우 : 왼쪽, 오.. 2024. 6. 21. 17:58
조건문 연습 - 2884 ## 2884 알람 시계h, m = input().split()h = int(h)m = int(m)if (h*60 + m) 2024. 6. 20. 22:40
조건문 연습 - 14691 ## 14691 사분면 고르기x = int(input())y = int(input())if x>0 and y>0 : print('1')elif x0: print('2')elif x 2024. 6. 20. 22:11
반복문 연습 - 2444 ## 2444 별찍기 - 7n = int(input())for i in range(1, 2*n): if i  백준에서 왜 틀렸다고 나오는지 모르겠다 2024. 6. 17. 23:22
반복문 연습 - 2439 ## 2438 별찍기n = int(input())for i in range(1, n+1): print('*' * i) 2024. 6. 11. 21:29
반복문 연습 - 25304 ## 25304 영수증x = int(input()) ## 총금액n = int(input()) ## 물건 종류tot = list()for i in range (1, n+1): a, b = input().split() a = int(a) b = int(b) tot_i = a*b tot.append(tot_i)if x == sum(tot): print('Yes')else: print('No') 2024. 6. 11. 21:12
반복문 연습 - 8393 ## 8393 합n = int(input())sum = 0for i in range(1, n+1): sum = i + sum i = i + 1print(sum) 2024. 6. 10. 21:01
반복문 연습 - 10950 ## 10950 A+B-3cnt = int(input())A = list()B = list()for i in range(0, cnt): A_i, B_i = input().split() A_i = int(A_i) B_i = int(B_i) A.append(A_i) B.append(B_i)for j in range(0, cnt): print(A[j] + B[j]) 2024. 6. 10. 19:53