일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
- 자바
- 백준 16918번
- 백준 2512번
- 깃헙
- 백준 18310번
- 백준
- HUFS 모각코 캠프
- 백준 15787번
- 백준 1253번
- javascript
- Python
- 모각코
- react
- AWS
- 그래프
- 백준 1331번
- 머신러닝과 딥러닝
- MySQL
- SQL
- 백준 1987
- 그리디
- 다이나믹 프로그래밍
- 명품자바
- java_programming
- 백준 17451번
- 다이나믹프로그래밍
- ubuntu
- SWEA 15612번
- 알고리즘
- 백준 3085번
- Today
- Total
목록전체 글 (238)
차곡차곡
코드트리 백트래킹 연습 - 특정 조건에 맞게 k개 중에 1개를 n번 뽑기 def calc(now): if now == n: cnt = 1 for i in range(n-1): if nums[i] == nums[i+1]: cnt += 1 if cnt == 3: return else: cnt = 1 # if cnt < 3: for el in nums: print(el, end=" ") print() return for i in range(1, k+1): nums.append(i) calc(now + 1) nums.pop() k, n = map(int, input().split()) nums = [] calc(0)
코드트리 백트래킹 연습 - 겹치지 않게 선분 고르기 def calc(): if 1 not in flag: return 0 last = -1 cnt = 0 for i in range(n): if flag[i]: if last == -1: last = lines[i][1] cnt += 1 else: if last < lines[i][0]: last = lines[i][1] cnt += 1 return cnt def including_line(now, most_cnt): if now == n: cnt = calc() if most_cnt < cnt: most_cnt = cnt return most_cnt for i in range(2): flag.append(i) most_cnt = including_line..
코드트리 백트래킹 연습 - 강력한 폭발 import sys sys.setrecursionlimit(10 ** 6) def cnt_bomb(): loc = [] for i in range(bomb_cnt): if bomb[i] == 1: y = bomb_loc[i][1] for x in range(-2, 3): if 0
코드트리 백트래킹 연습 - 아름다운 수 n자리 아름다운 수가 몇 개 있는지 구하는 프로그램 작성 def is_beautiful(): for i in range(n): if i == 0: now_num = ans[i] cnt = 1 elif now_num == ans[i]: cnt += 1 else: if cnt % now_num == 0: cnt = 1 now_num = ans[i] continue else: return False if cnt % now_num == 0: return True def choose_num(now): global cnt if now == n+1: if is_beautiful(): cnt += 1 return for i in range(1, 5): ans.append(i) c..
코드트리 백트래킹 연습 - k개 중에 1개를 n번 뽑기 1 이상 K 이하의 숫자를 하나 고르는 행위를 N번 반복하여 나올 수 있는 모든 서로 다른 순서쌍을 구해주는 프로그램 작성 def print_num(): for el in nums: print(el, end=" ") print() def choose_num(now): if now == n + 1: print_num() return for i in range(1, k+1): nums.append(i) choose_num(now+1) nums.pop() k, n = map(int, input().split()) nums = [] choose_num(1)
sort() 함수의 기본적 특징 - 기본적으로 오름차순 정렬한다. - 요소를 문자열로 캐스팅하고 변환된 문자열을 비교하여 순서를 결정한다. - 요소가 undefined인 경우, 문자열로 변환되지 않고 배열의 맨끝으로 정렬된다. var numbers = [1, 10, 2, 20, 3, 30]; numbers.sort(); console.log(numbers); // [1,10,2,20,3,30] 문자열 10과 문자열 2를 비교했을 때, '1' < '2' 이므로 10이 2보다 앞에 정렬된다. 위 문제를 해결하기 위해선, sort 함수에 비교 함수를 파라미터에 넣어줘야 한다. array.sort(compareFunction) 비교 함수(compareFunction) 1. 숫자 오름차순 정렬 var number..
JDoodle - Online Compiler, Editor for Java, C/C++, etc JDoodle is an Online Compiler, Editor, IDE for Java, C, C++, PHP, Perl, Python, Ruby and many more. You can run your programs on the fly online, and you can save and share them with others. Quick and Easy way to compile and run programs online. www.jdoodle.com stdin Inuts에 예제 입력 후 테스트
백준 #5073 삼각형과 세 변 5073번: 삼각형과 세 변 각 입력에 맞는 결과 (Equilateral, Isosceles, Scalene, Invalid) 를 출력하시오. www.acmicpc.net # 더러운 코드 while True: triangle = list(map(int, input().split())) if triangle[0] == 0 and triangle[1] == 0 and triangle[2] == 0: break max_x = -1 max_idx = -1 for i in range(3): # 가장 큰 변 구하기 if max_x < triangle[i]: max_x = triangle[i] max_idx = i hap = 0 # 두 변의 합 for i in range(3): if ..