์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
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 | 31 |
- ๋ฐฐ๋ญ๋ฌธ์
- heapq
- ์ฌ๊ท
- ๋ถํ ์ ๋ณต
- DP
- ๋ธ๋ฃจํธํฌ์ค
- ์๋ฎฌ๋ ์ด์
- ๋นํธ๋ง์คํน
- Java
- HashMap
- ํ๋ก๊ทธ๋๋จธ์ค
- dfs
- ํ๋ก์ด๋์์ฌ
- ๋ค์ต์คํธ๋ผ
- ๋ถ๋ถ์งํฉ
- ๊ตฌํ
- ํ์ด์ฌ
- ์ด๋ถํ์
- bfs
- Deque
- ์กฐํฉ
- ์๊ณ ๋ฆฌ์ฆ
- BOJ
- ์๋๋ก์ด๋
- Python
- ์ ๋ ฌ
- ๋ฌธ์์ด
- SQL
- ๋ฐฑํธ๋ํน
- 3์ฐจ์๋ฐฐ์ด
- Today
- Total
๋ชฉ๋ก์กฐํฉ (7)
It's easy, if you try
๋ฌธ์ https://programmers.co.kr/learn/courses/30/lessons/72411?language=java ์ฝ๋ฉํ ์คํธ ์ฐ์ต - ๋ฉ๋ด ๋ฆฌ๋ด์ผ ๋ ์คํ ๋์ ์ด์ํ๋ ์ค์นดํผ๋ ์ฝ๋ก๋19๋ก ์ธํ ๋ถ๊ฒฝ๊ธฐ๋ฅผ ๊ทน๋ณตํ๊ณ ์ ๋ฉ๋ด๋ฅผ ์๋ก ๊ตฌ์ฑํ๋ ค๊ณ ๊ณ ๋ฏผํ๊ณ ์์ต๋๋ค. ๊ธฐ์กด์๋ ๋จํ์ผ๋ก๋ง ์ ๊ณตํ๋ ๋ฉ๋ด๋ฅผ ์กฐํฉํด์ ์ฝ์ค์๋ฆฌ ํํ๋ก ์ฌ๊ตฌ์ฑํด์ programmers.co.kr ํ์ด import java.util.*; class Solution { static HashMap hm; public String[] solution(String[] orders, int[] course) { hm = new HashMap(); for(String o: orders) { char[] order = o.toCharArr..
10๊ฐ์ ์ ์ ๋ด๊ฐ 35๋ฒ ํ๋ฆฌ๊ณ ํฌ๊ธฐํ๋ ๋ฌธ์ ํ์๋ค โป ๋ฌธ์ 14502๋ฒ: ์ฐ๊ตฌ์ ์ธ์ฒด์ ์น๋ช ์ ์ธ ๋ฐ์ด๋ฌ์ค๋ฅผ ์ฐ๊ตฌํ๋ ์ฐ๊ตฌ์์์ ๋ฐ์ด๋ฌ์ค๊ฐ ์ ์ถ๋์๋ค. ๋คํํ ๋ฐ์ด๋ฌ์ค๋ ์์ง ํผ์ง์ง ์์๊ณ , ๋ฐ์ด๋ฌ์ค์ ํ์ฐ์ ๋ง๊ธฐ ์ํด์ ์ฐ๊ตฌ์์ ๋ฒฝ์ ์ธ์ฐ๋ ค๊ณ ํ๋ค. ์ฐ๊ตฌ์๋ ํฌ www.acmicpc.net ํ์ด import java.util.*; import java.io.*; public class Main_BOJ_14502_์ฐ๊ตฌ์ { static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer st; static int[][] map, mapClone; static int N, M, ma..
๋ฌธ์ 17135๋ฒ: ์บ์ฌ ๋ํ์ค ์ฒซ์งธ ์ค์ ๊ฒฉ์ํ ํ์ ์ N, ์ด์ ์ M, ๊ถ์์ ๊ณต๊ฒฉ ๊ฑฐ๋ฆฌ ์ ํ D๊ฐ ์ฃผ์ด์ง๋ค. ๋์งธ ์ค๋ถํฐ N๊ฐ์ ์ค์๋ ๊ฒฉ์ํ์ ์ํ๊ฐ ์ฃผ์ด์ง๋ค. 0์ ๋น ์นธ, 1์ ์ ์ด ์๋ ์นธ์ด๋ค. www.acmicpc.net ํ์ด 1 ๋ฉ๋ชจ๋ฆฌ์ ์๊ฐ์ด ์ข ๋ ๋์ ๋ฒ์ import java.util.*; import java.io.*; public class Main { static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer st; static int N, M, D; static int[][] castle; static int[][] castleClone; sta..
์ ์ Combinations (์กฐํฉ nCr) : ํ๋์ ๋ฆฌ์คํธ์์ ๋ชจ๋ ์กฐํฉ์ ๊ณ์ฐํด์ผํ ๋ ์ฌ์ฉํ๋ค. Permutations (์์ด nPr) ๊ณผ์ ์ฐจ์ด ์์ด์ ์์๊ฐ ๋ฐ๋ ๊ฒฝ์ฐ๋ ํฌํจํ๊ณ , ์กฐํฉ์ ์์๊ฐ ๋ฐ๋ ๊ฒฝ์ฐ๋ ํฌํจํ์ง ์๋๋ค(์์ ์๊ด ์์). ์๋ฅผ ๋ค์ด 1,2,3 ์ผ๋ก ์ด๋ฃจ์ด์ง ๋ฆฌ์คํธ์์ ์์ด์ (1,2),(1,3),(2,3),(2,1),(3,1),(3,2) ์กฐํฉ์ (1,2),(1,3),(2,3) ์ด๋ค. ์ฌ์ฉ ๋ฐฉ๋ฒ from itertools import combinations # itertools ์ค combinations๋ฅผ import โ items = ['1','2','3'] c = list(combinations(items,2)) # 2๊ฐ์ง ์กฐํฉ์ผ๋ก ์ด๋ฃจ์ด์ง ์ ์๋ ๋ชจ๋ ๊ฒฝ์ฐ์ ์๋ฅผ l..
์์ด ์๋ก ๋ค๋ฅธ n๊ฐ์ ์์ ์ค r๊ฐ๋ฅผ ์์ ์๊ฒ ๊ณจ๋ผ๋ธ ๊ฒ์ ์์ด(Permutation)์ด๋ผ๊ณ ํ๋ค. ์๋ ์ฝ๋๋ ์ฃผ์ฌ์๋ฅผ 3๋ฒ ๋์ก์ ๋ ๋์ฌ ์ ์๋ ๊ฒฝ์ฐ์ ์์ด๋ค. (์ค๋ณต X, ์์ O) // ์์ด : nPr ==> n! private static void dice2(int cnt) { if(cnt == N) { totalCnt++; System.out.println(Arrays.toString(numbers)); return; } for(int i =1; i n^r private static void dice1(int cnt) { if(cnt == N) { // ๊ธฐ์ ์กฐ๊ฑด totalCnt++; System.out.println(Arrays.toString(numbers)); return; } f..
๋ฌธ์ 3040๋ฒ: ๋ฐฑ์ค ๊ณต์ฃผ์ ์ผ๊ณฑ ๋์์ด ๋งค์ผ ๋งค์ผ ์ผ๊ณฑ ๋์์ด๋ ๊ด์ฐ์ผ๋ก ์ผ์ ํ๋ฌ ๊ฐ๋ค. ๋์์ด๊ฐ ์ผ์ ํ๋ ๋์ ๋ฐฑ์ค๊ณต์ฃผ๋ ๊ทธ๋ค์ ์ํด ์ ๋ ์์ฌ๋ฅผ ์ค๋นํ๋ค. ๋ฐฑ์ค๊ณต์ฃผ๋ ์์ ์ผ๊ณฑ๊ฐ, ์ ์ ์ผ๊ณฑ๊ฐ, ๋์ดํ ์ผ๊ณฑ๊ฐ๋ฅผ ์ค๋นํ๋ค. www.acmicpc.net ํ์ด import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static int[] capNum; static boolean[] isSelected; stati..
๋ฌธ์ ์ฝ๋ฉํ ์คํธ ์ฐ์ต - ์์ฅ programmers.co.kr ํ์ด ์ด ๋ฌธ์ ๋ ์๊ณ ๋ฆฌ์ฆ ์คํฐ๋์์ ์ค์์ธ๋๊ฐ ํ์ดํด์ค ๋ฌธ์ ์ธ๋ฐ, ๋ณต์ตํ๋ฉด ์ข์ ๊ฒ ๊ฐ์ ๋ค์ ํ์ด๋ณด๋ฉฐ ๊ณต๋ถํ ํ, ์ ๋ฆฌํ๋ค. from collections import Counter from functools import reduce def solution(clothes): count = Counter([category for name, category in clothes]) return reduce(lambda x, y : x * (y + 1), count.values(), 1) -1 ๋จผ์ ์๋ก ๋ค๋ฅธ ์์์ ์กฐํฉ์ ์๋ฅผ ๊ตฌํ๋ ๊ณต์ clothes๊ฐ [[yellow_hat, headgear], [blue_sunglasses, eyewear]..