목록코딩테스트 (21)
일상 코딩

Visual Studio에 헤더파일 추가하기 출처:https://hkhan.tistory.com/36 [C++] Visual Studio에 헤더파일 추가하기 알고리즘 문제를 풀 때, 필요한 헤더 파일들을 매번 include 해주는 과정이 귀찮게 느껴질 수 있다. 자주 쓰이는 헤더 파일들을 담은 stdc++.h 파일을 다운로드 받은 후, 코드 컴파일러의 include 파일 hkhan.tistory.com C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include 위 경로에서 "bits" 폴더 생성 후 "stdc++.h" 파일 넣는다. #include // include 신경쓰지 않고 코딩에만 집중 int ..

Visual Studio에 헤더파일 추가하기 출처:https://hkhan.tistory.com/36 [C++] Visual Studio에 헤더파일 추가하기 알고리즘 문제를 풀 때, 필요한 헤더 파일들을 매번 include 해주는 과정이 귀찮게 느껴질 수 있다. 자주 쓰이는 헤더 파일들을 담은 stdc++.h 파일을 다운로드 받은 후, 코드 컴파일러의 include 파일 hkhan.tistory.com C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include 위 경로에서 "bits" 폴더 생성 후 "stdc++.h" 파일 넣는다. #include // include 신경쓰지 않고 코딩에만 집중 int ..

Visual Studio에 헤더파일 추가하기 출처:https://hkhan.tistory.com/36 [C++] Visual Studio에 헤더파일 추가하기 알고리즘 문제를 풀 때, 필요한 헤더 파일들을 매번 include 해주는 과정이 귀찮게 느껴질 수 있다. 자주 쓰이는 헤더 파일들을 담은 stdc++.h 파일을 다운로드 받은 후, 코드 컴파일러의 include 파일 hkhan.tistory.com C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include 위 경로에서 "bits" 폴더 생성 후 "stdc++.h" 파일 넣는다. #include // include 신경쓰지 않고 코딩에만 집중 int ..

Visual Studio에 헤더파일 추가하기 출처:https://hkhan.tistory.com/36 [C++] Visual Studio에 헤더파일 추가하기 알고리즘 문제를 풀 때, 필요한 헤더 파일들을 매번 include 해주는 과정이 귀찮게 느껴질 수 있다. 자주 쓰이는 헤더 파일들을 담은 stdc++.h 파일을 다운로드 받은 후, 코드 컴파일러의 include 파일 hkhan.tistory.com C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include 위 경로에서 "bits" 폴더 생성 후 "stdc++.h" 파일 넣는다. #include // include 신경쓰지 않고 코딩에만 집중 int ..

C++ 온라인 컴파일러 사이트 https://replit.com/~ https://www.onlinegdb.com/online_c++_compiler https://cpp.sh/ https://www.tutorialspoint.com/compile_cpp_online.php #include #include #include #include #include #include #include using namespace std; bool prime(int num) { bool bprime = true; for (int i = 2; i < num ; i++) { if (num % i == 0) { bprime = false; break; } } return bprime; } int main() { ios_base..

C++ 온라인 컴파일러 사이트 https://replit.com/~ https://www.onlinegdb.com/online_c++_compiler https://cpp.sh/ https://www.tutorialspoint.com/compile_cpp_online.php 25. 석차 구하기 N명의 학생의 수학점수가 입력되면 각 학생의 석차를 입려된 순서대로 출력하는 프로그램을 작성하세요. 입력설명 첫 줄에 N(1 > rank; // 등수 리스트 cin >> N; for (int i = 0; i > a; score.push_back(make_pair(i+1, a)); } auto desc = [](pair a, pair b) { return a.second > b.seco..
https://www.acmicpc.net/problem/2110 2110번: 공유기 설치 첫째 줄에 집의 개수 N (2 ≤ N ≤ 200,000)과 공유기의 개수 C (2 ≤ C ≤ N)이 하나 이상의 빈 칸을 사이에 두고 주어진다. 둘째 줄부터 N개의 줄에는 집의 좌표를 나타내는 xi (0 ≤ xi ≤ 1,000,000,000)가 www.acmicpc.net N, C = map(int, input().split()) X = sorted([int(input()) for _ in range(N)]) sta = X[1] - X[0] end = X[-1] - X[0] result = 0 while sta = val + mid: val = X[i] cnt += 1 if cnt >= C: sta = mid + ..
https://www.acmicpc.net/problem/1236 1236번: 성 지키기 첫째 줄에 성의 세로 크기 N과 가로 크기 M이 주어진다. N과 M은 50보다 작거나 같은 자연수이다. 둘째 줄부터 N개의 줄에는 성의 상태가 주어진다. 성의 상태는 .은 빈칸, X는 경비원이 있는 칸이다 www.acmicpc.net N, M = map(int, input().split()) B = [list(input()) for _ in range(N)] cnt = 0 def X_check(arr): ret = 0 for i in arr: if 'X' in i: continue else: ret += 1 return ret def rotated(array_2d): return [list(elem) for elem..
https://www.acmicpc.net/problem/1302 1302번: 베스트셀러 첫째 줄에 오늘 하루 동안 팔린 책의 개수 N이 주어진다. 이 값은 1,000보다 작거나 같은 자연수이다. 둘째부터 N개의 줄에 책의 제목이 입력으로 들어온다. 책의 제목의 길이는 50보다 작거나 같고 www.acmicpc.net N = int(input()) S = dict() for _ in range(N): book = input() if book not in S: S[book] = 0 S[book] += 1 print(sorted(list(S.items()), key=lambda x: (-x[1], x[0]))[0][0]) 입력 예제 8 icecream peanuts peanuts chocolate candy..
https://www.acmicpc.net/problem/1543 1543번: 문서 검색 세준이는 영어로만 이루어진 어떤 문서를 검색하는 함수를 만들려고 한다. 이 함수는 어떤 단어가 총 몇 번 등장하는지 세려고 한다. 그러나, 세준이의 함수는 중복되어 세는 것은 빼고 세야 한 www.acmicpc.net Q = input() A = input() cnt = 0 while Q: if Q[:len(A)] == A: cnt += 1 Q = Q[len(A):] else: Q = Q[1:] print(cnt) 입력 예제 ababababa aba 출력 예제 2 슬라이싱을 활용하여 풀어보았다. while문 종료 조건을 Q가 '' 완전히 빌때까지로 놓았고, 앞부분부터 정답 문자열 길이만큼 슬리이싱한 부분이 A 정답과..