본문 바로가기

알고리즘50

[백준] 3003번: 킹, 퀸, 룩, 비숍, 나이트, 폰 - java 풀이 체스를 할때 원래 필요한 피스의 개수를 미리 배열에 넣어주고 입력 받은 킹, 퀸, 룩, 비숍, 나이트, 폰의 피스의 개수를 빼주면 되는 문제다. split() 이용 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int[] chess = {1,1,2,2,2,8}; String[] chCnt = br.readLine()... 2023. 6. 21.
[백준] 2908번: 상수 - java 풀이 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 = new StringTokenizer(br.readLine()); String A = st.nextToken(); String B = st.nextToken(); int San.. 2023. 6. 21.
[백준] 2675번: 문자열 반복 - java 풀이 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)); int T = Integer.parseInt(br.readLine()); StringBuilder sb = new StringBuilder(); for(int i=0; i 2023. 6. 19.
[백준] 9086번: 문자열 - java 풀이 getBytes() 이용한 풀이 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int T = Integer.parseInt(br.readLine()); StringBuilder sb = new StringBuilder(); for(int i=0; i 2023. 6. 19.
[백준] 2743번: 단어 길이 재기 - java 풀이 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); // 첫번째 풀이 //String[] arr = br.readLine().split(""); //System.out.println(arr.length); //두번째 풀이 //byte[] arr = br.readLine().getBytes(); //System.out.pri.. 2023. 6. 19.
[백준] 11718번: 그대로 출력하기 - java 풀이 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String str=""; StringBuilder sb = new StringBuilder(); while((str=br.readLine())!=null) { sb.append(str+"\n"); } br.close(); System.out.println(sb); } .. 2023. 6. 18.