알고리즘/구현 (29) 썸네일형 리스트형 자바 | 백준 | 11866 | 요세푸스 문제 0 | LinkedList Solution 삭제가 계속 이루어짐 --> LinkedList 이용 // 11866, 요세푸스 문제 0 package BOJ; import java.io.*; import java.util.*; public class BOJ_11866 { public static void main(String[] args) throws IOException{ // TODO Auto-generated method stub BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); StringTokenizer st .. 자바 | 파이썬 | 백준 | 10250 | ACM 호텔 solution 1. N이 H의 배수인 경우와 아닌 경우를 나눠서 생각한다. Java // 10250, ACM 호텔 import java.io.*; import java.util.*; public class BOJ_10250 { public static void main(String[] args) throws IOException { // TODO Auto-generated method stub BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int T = Integer.parseInt(br.readLine()); int H, W, N; for (int i = 0; i < T; i++) { StringTokenizer s.. 자바 | 백준 | 10807 | 개수 세기 solution 1. HashMap 이용 ∵ v가 몇 개인지 출력 // 10807, 개수 세기 package BOJ; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.HashMap; import java.util.StringTokenizer; public class BOJ_10807 { public static void main(String[] args) throws IOException { // TODO Auto-generated method stub BufferedReader br = new BufferedReader(new InputStreamReade.. 자바 | 파이썬 | 백준 | 2164 | 카드2 | Deque solution 1. 덱(Deque) 사용 ∵ 양 옆에서 삭제. 삽입 java // 2164, 카드2 import java.util.ArrayDeque; import java.util.Deque; import java.util.Scanner; public class BOJ_2164 { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int N = sc.nextInt(); Deque d = new ArrayDeque(); for (int i=1;i1) { d.pollFirst(); d.add(d.pollFirst()); } System.out.printl.. 자바 | 백준 | 1978 | 소수 찾기 solution 1. isPrime() : 소수 판별 함수 // 1978, 소수 찾기 import java.util.Scanner; public class BOJ_1978 { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int res = 0; for (int i = 0; i < N; i++) { int input = sc.nextInt(); if (isPrime(input)) { res++; } } System.out.println(res); } static boolean isPrime(int x) { if (.. 자바 | 백준 | 1259 | 팰린드롬수 solution // 1259, 팰린드롬수 import java.util.Arrays; import java.util.Scanner; public class BOJ_1259 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s; while (true) { s = sc.next(); if (s.equals("0")) break; char [] chars = new char[s.length()]; for (int i=0;i 파이썬 | 백준 | 3985 | 롤 케이크 | array.index solution 1. 여러 명인 경우에는 번호가 작은 사람 출력 → array.index() # 3985, 롤 케이크 import sys L = int(sys.stdin.readline()) cake = [0] * (L + 1) N = int(sys.stdin.readline()) audience = [0] * (N + 1) M_idx, M_cnt = 0, 0 for i in range(1, N + 1): P, K = map(int, sys.stdin.readline().split()) if K - P - 1 > M_cnt: M_idx = i M_cnt = K-P-1 cnt = 0 for j in range(P, K + 1): if not cake[j]: cake[j] = 1 cnt += 1 audien.. 파이썬 | 백준 | 1251 | 단어 나누기 | 문자열 reverse solution 임의의 두 부분 → 조합(combinations) 문자열 reverse → [string][::-1] # 1251, 단어 나누기 import sys from itertools import combinations s = sys.stdin.readline().rstrip() candidates = [i for i in range(1, len(s))] comb_candidates = list(combinations(candidates, 2)) res = "z"*len(s) # 사전에서 가장 뒤에 오는 문자열 임의로 설정 for comb_candidate in comb_candidates: split1, split2 = comb_candidate[0], comb_candidate[1] # [::.. 이전 1 2 3 4 다음