Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@
<ul><li>골드1달성하기</li></ul>
</td>
<td align="center"></td>
<td align="center"></td>
<td align="center">
<ul><li> 백준 골드 입성</li></ul>
<ul><li> 주요 라이브러리 적응</li></ul>
<ul><li> 삼성 기출 풀이시간 단축(3h)</li></ul>
<ul><li> B형 도전하기</li></ul>
</td>
</tr>
</table>

Expand Down
53 changes: 51 additions & 2 deletions src/ji/week1/day1/P_경로찾기_11403.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,54 @@
package ji.week1.day1;
package com.solve.backjun;

public class P_경로찾기_11403 {
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
public static int[][] map;
public static int N;

public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
// BufferedReader br = new BufferedReader(new FileReader("input.txt"));

// 수업시간에 배웠던 내용
// readLine()으로 받아올 String 객체를 기본형 타입인 int와 형변환이 안되므로
// Wrapper Class 사용 (Integer) ==> int 타입 변수를 객체로 포장함
N = Integer.parseInt(br.readLine());
map = new int[N][N];

for (int h=0; h<N; h++) {
String line[] = br.readLine().split(" ");
for (int w=0; w< N; w++) {
map[h][w] = Integer.parseInt(line[w]);
}
}
// <거쳐간다> 키워드 => 플로이드 => 공식 Dab = min(Dab, Dak+Dkb)
for (int k=0; k<N; k++) {
for (int a=0; a<N; a++) {
for (int b=0; b<N; b++) {
if (map[a][k] == 1 && map[k][b] == 1) {
map[a][b] = 1;
}
}
}
}
print();
}
// 너무 공식에 얽메여서 오히려 돌아갔던 문제, 일반적인 플로이드는 0자리 대신 INF로 설정하면
// Dak+Dkb (a -> k -> b) 경로가 없을 때 값이 너무커져서 걸러지는데,
// 여긴 간선이 없을 땐 0이라서 공식을 사용하면 모든 자리에 값이 들어가버려 원인을 찾는 데 시간이 걸렸다.
// 3중 반복문 변수 순서도 주의할 것 (k a b)

private static void print() {
StringBuilder sb = new StringBuilder();
for (int h=0; h<N; h++) {
for (int w=0; w<N; w++) {
sb.append(map[h][w] + " ");
}
sb.append("\n");
}
System.out.println(sb);
}
}
40 changes: 40 additions & 0 deletions src/ji/week1/day1/P_팩토리얼 0의 개수_1676.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();

int answer = factorial(N);

System.out.println(answer);

}

public static int factorial(int N) {
int zero_count = 0;
int sum=1;

for (int i = N; i > 1; i--) {
sum = sum * i;
// 오버플로우를 방지하는 것이 문제의 핵심
// 뒤에 0이 있는 숫자는 무엇을 곱해도 0이 유지가 되므로
// 0을 따로 카운트하고 자리수를 줄인다.
while(sum > 0) {
int temp = sum % 10;
if (temp == 0) {
zero_count++;
sum = sum / 10;
} else {
break;
}
}
if (sum==0) { // 0 곱해지는 현상 방지 (ex : 100!)
sum = 1;
} else if(sum > 1000000) { // 단순 숫자로만 자리수를 채운다면 4자리만큼만 잘라낸다.
sum = sum % 10000;
}
}
return zero_count;
}
}
101 changes: 101 additions & 0 deletions src/ji/week1/day1/week2/day1/P_뱀_3190.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;

public class Main {
public static int[][] map;
public static int time =0;
public final static int[][] direct = {{0,1},{1,0},{0,-1},{-1,0}};
public static int now_direct = 0;
public static int now_h = 0;
public static int now_w = 0;
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
HashMap<Integer, String> hm = new HashMap<>();

int N = Integer.parseInt(br.readLine());
map = new int[N][N];
// snake queue
Queue<Point> queue = new LinkedList<>();

int N_apple = Integer.parseInt(br.readLine());
for (int i = 0; i < N_apple; i++) {
StringTokenizer st = new StringTokenizer(br.readLine());
int temp_h = Integer.parseInt(st.nextToken());
int temp_w = Integer.parseInt(st.nextToken());
map[temp_h-1][temp_w-1] = 2;
}

int N_angle = Integer.parseInt(br.readLine());;
for (int i = 0; i < N_angle; i++) {
StringTokenizer st = new StringTokenizer(br.readLine());
int key = Integer.parseInt(st.nextToken());
String value = st.nextToken();
hm.put(key, value);
}

map[0][0] = 1;
queue.add(new Point(0,0));


while (true) {
time++;
int next_h = now_h + direct[now_direct][0];
int next_w = now_w + direct[now_direct][1];
if(next_h >= N || next_h < 0 || next_w >= N || next_w < 0) {
break;
}

if (map[next_h][next_w] == 2) { // 사과 좌표로 이동
now_h = next_h;
now_w = next_w;
queue.add(new Point(next_h,next_w));
map[next_h][next_w] = 1;
} else if (map[next_h][next_w] == 1) { // 본인 꼬리 밟음
break;
} else { // 빈 공간으로 이동
map[next_h][next_w] = 1;
now_h = next_h;
now_w = next_w;
Point p = queue.poll();
map[p.x][p.y] = 0;
queue.add(new Point(next_h,next_w));
}

if (hm.containsKey(time)) {
String move_to = hm.get(time);
if (move_to.equals("D")) {
now_direct++;
} else {
now_direct--;
}
if (now_direct >= 4) {
now_direct = now_direct % 4;
}
if (now_direct < 0) {
now_direct += 4;
}
}
}

System.out.println(time);

}

// public static void print(int n) {
// StringBuilder sb = new StringBuilder();
// for (int i=0; i<n; i++) {
// for (int j=0; j<n; j++) {
// sb.append(map[i][j] + " ");
// }
// sb.append("\n");
// }
// System.out.println(sb);
// }

}
40 changes: 40 additions & 0 deletions src/ji/week1/day2/P_팩토리얼 0의 개수_1676.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();

int answer = factorial(N);

System.out.println(answer);

}

public static int factorial(int N) {
int zero_count = 0;
int sum=1;

for (int i = N; i > 1; i--) {
sum = sum * i;
// 오버플로우를 방지하는 것이 문제의 핵심
// 뒤에 0이 있는 숫자는 무엇을 곱해도 0이 유지가 되므로
// 0을 따로 카운트하고 자리수를 줄인다.
while(sum > 0) {
int temp = sum % 10;
if (temp == 0) {
zero_count++;
sum = sum / 10;
} else {
break;
}
}
if (sum==0) { // 0 곱해지는 현상 방지 (ex : 100!)
sum = 1;
} else if(sum > 1000000) { // 단순 숫자로만 자리수를 채운다면 4자리만큼만 잘라낸다.
sum = sum % 10000;
}
}
return zero_count;
}
}
44 changes: 44 additions & 0 deletions src/ji/week1/day3/P_부녀회장이 될테야_2775.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import java.util.Arrays;
import java.util.Scanner;

public class Main {
public static int a;
public static int b;
public static int[] room;

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();

for (int t = 0; t < T; t++) {
a = sc.nextInt();
b = sc.nextInt();
room = new int[b];
for (int i = 0; i < b; i++) {
room[i] = i+1;
}

recur(1);
System.out.println(room[b-1]);

}
return;
}

public static void recur(int floor) {

for (int i = b-1; i >= 0; i--) {
for (int j = 0; j < i; j++) {
room[i] += room[j];
}
}

if (floor == a) {
return;
}
floor++;
recur(floor);
return;
}

}