본문 바로가기
반응형
반응형

프로그래밍20

반응형
[greedy] 1이 될때까지 1. 내 정답 n, k = list(map(int, input().split())) result = 0 while n>= k: while n % k != 0: n-=1 result += 1 n //= k result += 1 while n>1: n-=1 result += 1 print(result) 2. 원래 답 n, k = map(int, input().split()) result = 0 while True: target = (n // k) * k result += (n - target) n = target if n < k: break result += 1 n //= k result += (n-1) print(result) 2022. 3. 19.
[greedy] 숫자 카드 게임 1. 내 정답 n, m = list(map(int, input().split())) result = 0 for i in range(n): data = list(map(int, input().split())) data.sort(reverse = True) result = data[n-1] print(result) 2. 원래 답 n, m = list(map(int, input().split())) result = 0 for i in range(n): data = list(map(int, input().split())) min_value = 10001 for a in data: min_value = min(min_value, a) result = max(result, min_value) print(result) 2022. 3. 19.
[greedy] 큰 수의 법칙 1. 내 정답 import time times = time.time() n, m ,k = list(map(int, input().split())) data = list(map(int, input().split())) data.sort() print(data) first = data[n-1] print(first) second = data[n-2] print(second) count = 0 while True: for i in range(k): if m != 0: count += first m -= 1 if m != 0: count += second m-= 1 if m == 0: break timese = time.time() print('시간 :', timese - times) print(count) 2.. 2022. 3. 19.
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject 에러 해결 개발환경 - ubuntu 18.04 - pycham 2020.3.3 - python 3.7 1. Problem numpy가 아닌 다른 라이브러리를 사용하려는데 numpy에서 에러가 발생했다. 2. Reason numpy버전이 해당 라이브러리에 맞지 않지 않다는 뜻이다. 3. Solution 해결방법은 매우 간단한데 numpy를 새로 설치하거나 !pip uninstall numpy !pip install numpy 아에 최신버전으로 업그레이드 하는 방법이 있다. !pip upgrade numpy 2022. 3. 17.
반응형