문제풀이

    백준 1065. 한수(JAVA)

    백준 1065. 한수(JAVA)

    import java.util.Scanner; public class Main { public static void main(String[] arge) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int num = Hansu(N); System.out.println(num); } public static int Hansu(int N) { int cnt = 0; // 한수 개수를 세기 위한 변수 for(int i = 1 ; i = 100 & i

    백준 4673. 셀프 넘버(JAVA)

    백준 4673. 셀프 넘버(JAVA)

    ○ 문제 요약 정수와 해당 정수의 자릿수에 있는 값을 더해서 만든 것을 셀프 넘버라고 한다. 예를 들어, 99라는 정수에 99 + 9 + 9 = 117이 나오는데 이때 99를 '생성자'라고 하는데 생성자가 없는 수를 '셀프 넘버'라고 한다. 셀프 넘버가 출력되도록 프로그램을 작성해라. ○ 문제 풀이 1 public class Main { public static void main(String[] arge) { boolean[] boolarr = new boolean[10001]; for(int i = 1 ; i < 10001; i++) { int n = SelfNumber(i); if(n < 10001) { boolarr[n] = true; } } for(int i = 1; i < 10001; i++) ..

    백준 4344. 평균은 넘겠지(JAVA)

    백준 4344. 평균은 넘겠지(JAVA)

    import java.util.Scanner; public class Main { public static void main(String[] arge) { Scanner sc = new Scanner(System.in); int test_case = sc.nextInt(); // 테스트 케이스 int score = 0; // 총점을 구하기 위한 변수 int cnt = 0; // 평균을 넘는 인원이 몇명인지 카운트하는 변수 double result = 0; // 비율을 구하는 변수 for(int i = 0 ; i < test_case; i++) { int[] arr = new int[sc.nextInt()]; // 인원 수만큼 배열을 만듦. for(int j = 0 ; j < arr.length; j++)..

    백준 1260. DFS와 BFS(JAVA)

    백준 1260. DFS와 BFS(JAVA)

    import java.io.IOException; import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; import java.util.Stack; public class Main { static int n , m , v; // 정점, 간선, 시작 정점 static int[][] graph; // static boolean Visit[]; // 방문하였는지 확인하기 위해 static Stack st = new Stack(); static Queue q = new LinkedList(); public static void main(String[] args) throws IOException { Scanner sc = ne..

    백준 1110. 더하기 사이클(JAVA)

    백준 1110. 더하기 사이클(JAVA)

    import java.util.Scanner; public class Main { public static void main(String[] arge) { Scanner sc = new Scanner(System.in); int input = sc.nextInt(); int new_num = input; int cnt = 0; while(true) { int num1 = input / 10; int num2 = input % 10; input = num1 + num2; input = input % 10; input = (num2 * 10) + input; cnt++; if(new_num == input) { break; } } System.out.println(cnt); } } ○ 문제 요약 숫자를 입력..

    백준 16173. 점프왕 쩰리(Small)(JAVA)

    백준 16173. 점프왕 쩰리(Small)(JAVA)

    import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int[][] gameArea = new int[a][a]; boolean[][] visited = new boolean[a][a]; for(int i = 0 ; i < gameArea.length ; i++) { for(int j = 0 ; j < gameArea.length; j++) { gameArea[i][j] = sc.nextInt(); visi..

    백준 1715. 카드 정렬하기(JAVA)

    백준 1715. 카드 정렬하기(JAVA)

    import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.PriorityQueue; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int card_case = Integer.parseInt(br.readLine()); PriorityQueue pq = new PriorityQueue(); int result = 0; for(int i = 1 ..

    백준 1927. 최소 힙(JAVA)

    백준 1927. 최소 힙(JAVA)

    import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.PriorityQueue; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader( new InputStreamReader(System.in)); int num_cnt = Integer.parseInt(br.readLine()); PriorityQueue pq= new PriorityQueue(); for(int i = 0 ; i < num_cnt ; i+..

    백준 10773. 제로(JAVA)

    백준 10773. 제로(JAVA)

    import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Stack; public class B10733 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int input_num = Integer.parseInt(br.readLine()); Stack sta = new Stack(); int result = 0; for(int i = 0 ; i < input_num ; i++..

    백준 10828. 스택(JAVA)

    백준 10828. 스택(JAVA)

    import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Stack; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer stringTokenizer; int order_num = Integer.parseInt(br.readLine()); // String을 ..