1. Java 구현 import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; public class Main { public static void main(String[] args) { System.out.println(bfs(Integer.parseInt(new Scanner(System.in).nextLine()))); } private static int bfs(final int s) { final Queue queue = new LinkedList(); final boolean[][] visited = new boolean[1000 + 1][1000 + 1]; // [screen][board] queue.add(n..
1. Java 구현 import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.Queue; import java.util.Scanner; public class Main { public static void main(String[] args) { final Scanner scanner = new Scanner(System.in); final String[] firstLine = scanner.nextLine().split(" "); final boolean[][] maps = new boolean[Integer.parseInt(firstLine[0])][Integer.parseInt(firs..
1. Java 구현 (1) 풀이 - 1 (성공) (수정 필요) package Q1159; import java.io.*; import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); int n = Inte..
1. Java 구현 import java.util.Scanner; public class Main { private static final int PERIOD = 1500000; private static final int DIVIDE = 1000000; public static void main(String[] args) { System.out.println(fibonacci(new Scanner(System.in).nextLong(), PERIOD, DIVIDE)); } public static int fibonacci(long number, int period, int divide) { if(number
1. Java 구현 package Q1038; import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { System.out.println(solve(new Scanner(System.in).nextInt())); } public static String solve(int n) { if(n < 10) return String.valueOf(n); Queue decreases = new LinkedList(); for (int i = 0; i < 10; i++) decreases.add(String.valueOf(i)); int result = 9; whi..
1. Java 구현 import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); String[] input = br.readLine().split(" "); int a = Integer.parseInt(input[0]); int b = Integer.parseInt(input[1]); inpu..
1. Java 구현 package stream; import java.io.*; import java.util.*; import java.util.concurrent.ConcurrentLinkedQueue; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); StringBuilder sb = new StringBuilder(); int t = Inte..
1. Java 구현 import java.io.*; import java.util.Scanner; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new StringBuilder(); String a = br.readLine(); char op = br.readLine().charAt(0); String b = br.readLine(); if(a.length() < b.length()) { String temp = a; a = b; b = temp..
1. Java 구현 package Q1371; import java.io.*; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); StringBuilder sb = new StringBuilder(); char[] arr = new char[26]; int max = 0; while(sc.hasNextLine()) { char[] input = sc.nextLine().toCharArray(); for (int i = 0; i < input.length; i++) if (input[i] != ' ') max = Math.max(max, ..
1. Java 구현 (1) 시간초과 : 시간복잡도 O(n^2) → 실패 import java.io.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); StringBuilder sb = new StringBuilder(); int t = Integer.parseInt(br.readLine()); for(int i = 0; i < t; i++) { ..