알고리즘48 백준 BOJ 6064번 - 카잉 달력 코드 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main{ public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st; int num = Integer.parseInt(br.readLine()); for(int i = 0; i < num; i++) { st = new StringTokeni.. 2022. 9. 23. 백준 BOJ 4949번 - 균현잡힌 세상 접근 방법 스택의 원리를 이용하여 구현하면 쉽게 해결할 수 있다. 스택에 왼쪽 괄호를 먼저 저장하고, 그 다음 오는 오른쪽 괄호가 짝이 맞는지 확인하면 완전한 문장인지 체크할 수 있다. 코드 import java.util.Scanner; import java.util.Stack; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); String s; while(true){ s = in.nextLine(); if(s.equals(".")) break; System.out.println(checkPerfect(s)); } } public static String checkPerfect(S.. 2022. 9. 7. 백준 BOJ 5525번 - IOIOI 코드 import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int N = in.nextInt(); int M = in.nextInt(); char S[] = in.next().toCharArray(); int answer = 0, count = 0; for(int i = 1; i < M - 1; i++) { if(S[i] == 'O' && S[i + 1] == 'I'){ count++; if(count == N) { if(S[i - (N * 2 - 1)] == 'I') answer++; count--; } i++; } else count = 0; }.. 2022. 9. 5. 백준 BOJ 4153번 - 직각삼각형 코드 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); while(true) { int x = in.nextInt(); int y = in.nextInt(); int z = in.nextInt(); if(x == 0 && y == 0 && z == 0) break; if((x * x + y * y) == z * z) { System.out.println("right"); } else if(x * x == (y * y + z * z)) { System.out.println("right"); } else if(y * y == (z * z .. 2022. 9. 5. 이전 1 2 3 4 ··· 12 다음