본문 바로가기

프로그래밍/Baekjoon

(52)
(파이썬) 백준 알고리즘 10422번 괄호 문제풀이 (Python) 123456789101112131415161718192021def binomial(n, k): res = 1 for i in range(k): res = res*(n-i) res = res//(i+1) return res def catalan(n): c = binomial(2*n, n) return c//(n+1) T = int(input()) for i in range(T): n = int(input()) if n % 2 != 0: print(0) continue print(catalan(n//2)%1000000007)cs키워드 (Keyword)키워드 카탈란수 참조https://ko.wikipedia.org/wiki/%EC%B9%B4%ED%83%88%EB%9E%91_%EC%88..
(자바) 백준 알고리즘 10250번 ACM 호텔 문제풀이 (Java) 12345678910111213141516171819202122import java.util.Scanner; public class AcmHotel { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int T = sc.nextInt(); for(int i = 0; i
(자바) 백준 알고리즘 2292번 벌집 문제풀이 (Java)12345678910111213141516171819202122public class Main{ public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int target = sc.nextInt(); int cnt = 1; int range = 1; int tmp = 1; while(true) { if(range >= target) { break; } tmp = 6*(cnt++); range += tmp; } System.out.println(cnt); }}Colored by Color Scriptercs1칸 - 12칸 - 2~73칸 - 8..
(파이썬) 백준 알고리즘 5622번 다이얼 문제풀이 (Python) 12345678dial = ['ABC', 'DEF', 'GHI', 'JKL', 'MNO', 'PQRS', 'TUV', 'WXYZ']a = input()ret = 0for j in range(len(a)): for i in dial: if a[j] in i: ret += dial.index(i)+3print(ret)Colored by Color Scriptercs문제 출처https://www.acmicpc.net/problem/5622
(파이썬) 백준 알고리즘 2908번 상수 문제풀이 (Python) 123456A, B = input().split()A = A[::-1]B = B[::-1]ret = max(A, B) print(ret)cs알고리즘 분류문자열 문제 출처https://www.acmicpc.net/problem/2908
(파이썬) 백준 알고리즘 1316번 그룹 단어 체커 문제풀이 (Python) 12345678910111213141516171819cnt = 0;N = int(input())for i in range(N): check= [0]*26 flag = 1; word = input() n = len(word) for j in range(n): if check[ord(word[j])- 97]: if word[j] != word[j-1]: flag = 0; break check[ord(word[j])-97] = 1 check = [0]*26 if flag: cnt +=1print(cnt)cs문제 출처https://www.acmicpc.net/problem/1316
(C++) 백준 알고리즘 1074번 Z 문제풀이 (C++) 123456789101112131415161718192021222324252627282930#include #include using namespace std; int N, r, c, cnt; void recursion(int row, int col, int range){ if (row == r && col == c){ cout N >> r >> c; recursion(0, 0, pow(2, N)); return 0;}Colored by Color Scriptercs example 문제 출처https://www.acmicpc.net/problem/1074
(C++) 백준 알고리즘 7576번 토마토 문제풀이 (C++) 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081#include #include #include using namespace std; bool check[1003][1003] = {false,};int dist[1003][1003];int box[1003][1003];int dx[] = {0,0,1,-1};int dy[] = {1,-1,0,0}; int main(){ int M, N; int i,j; scanf("%d %d",&M,&N); for(i = 0; i