Computer Science (CS)/알고리즘

Computer Science (CS)/알고리즘

[백준/Java] 1193번 분수찾기

문제 정답 풀이 import java.io.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int X = Integer.parseInt(br.readLine()); int top = 1; int bottom = 1; int line = 1; int n = 1; if(X==1) System.out.print(top+"/"+bottom); else{ while(n < X) { line++; n += line; } // 짝수행 if(line%2==0){ top = line; for..

Computer Science (CS)/알고리즘

[백준/Java] 2292번 벌집

문제 정답 풀이 import java.io.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int N = Integer.parseInt(br.readLine()); int count = 1; int range = 2; if(N == 1){ System.out.print(1); } else{ while(range

Computer Science (CS)/알고리즘

[백준/Java] 2903번 중앙 이동 알고리즘

문제 정답 풀이 import java.io.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int N = Integer.parseInt(br.readLine()); int dot = (int)Math.pow(2, N) + 1; System.out.print(dot*dot); br.close(); } } 메모리 14088KB 시간 120ms 규칙을 찾으면 금방 풀 거 같은데 계속 못찾고 삽질하다가 4 -> 3*3 -> 5*5로 늘어나는데 3과 5 는 2^1만큼 늘어난다고 생각해..

Computer Science (CS)/알고리즘

[백준/Java] 2720번 세탁소 사장 동혁

문제 정답 풀이 import java.io.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new StringBuilder(); int Quarter = 25; int Dime = 10; int Nickel = 5; int Penny = 1; int T = Integer.parseInt(br.readLine()); for(int i = 0; i < T; i++) { int C = Integer.parseInt(br.readLine()); sb..

Computer Science (CS)/알고리즘

[백준/Java] 11005번 진법 변환 2

문제 정답 풀이 import java.io.*; 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()); StringBuilder sb = new StringBuilder(); int N = Integer.parseInt(st.nextToken()); int B = Integer.parseInt(st.nextToken()); wh..

Computer Science (CS)/알고리즘

[백준/Java] 2745번 진법 변환

문제 정답 풀이 import java.io.*; 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 N = st.nextToken(); int B = Integer.parseInt(st.nextToken()); int answer = 0; int tmp = 1; for(int i = N.length()-1; i>..

Computer Science (CS)/알고리즘

[백준/Java] 2563번 색종이

문제 정답 풀이 import java.io.*; 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[][] white = new int[100][100]; int papaerNum = Integer.parseInt(br.readLine()); int total = 0; for(int i = 0; i < papaerNum; i++){ st = new StringTokenizer(br...

Computer Science (CS)/알고리즘

[백준/Java] 10798번 세로읽기

문제 정답 풀이 import java.io.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); char[][] arr = new char[5][15]; String str = ""; for(int i = 0; i < arr.length; i++){ str = br.readLine(); for(int j = 0; j < str.length(); j++){ arr[i][j] = str.charAt(j); } } for(int j = 0; j < 15; j++){ for(int i =..

Computer Science (CS)/알고리즘

[백준/Java] 2566번 최댓값

문제 정답 풀이 import java.io.*; 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[][] arr = new int[9][9]; int max = 0; int first = 0; int second = 0; for(int i = 0; i < 9; i++){ st = new StringTokenizer(br.readLine()); for(int j = 0; j < 9;..

Computer Science (CS)/알고리즘

[백준/Java] 2738번 행렬 덧셈

문제 정답 풀이 import java.io.*; 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()); int N = Integer.parseInt(st.nextToken()); int M = Integer.parseInt(st.nextToken()); int[][] A = new int[N][M]; int[][] B = new..

eune7
'Computer Science (CS)/알고리즘' 카테고리의 글 목록 (4 Page)