
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n;//거스름돈 금액 int x = 0;//동전 개수 n = sc.nextInt(); while(n >= 5) { if(n == 8 || n == 6)//8과 6은 2로 거슬러줘야함 break; n-= 5; x++; } if(n % 2 == 0) { while(n >= 2) { n-=2; x++; } System.out.println(x); } else { System.out.println(-1); } } } 이번 문제는 나름 쉽게 푼 것 같다.

import java.util.Scanner; public class Day8 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = 0, cnt = 0;//N, 좋은 수 개수 N = sc.nextInt(); int[] numArr = new int[N]; for (int i = 0; i < numArr.length; i++) { numArr[i] = sc.nextInt(); } for (int k = 0; k < numArr.length; k++) { for (int i = 0; i < k; i++) {//2개씩 더함, 더할 숫자가 numArr[k]보다 크면 넘어감 for (int j = i+1; j ..

import java.util.Scanner; public class Day7 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = 0, M = 0; int time=0; N = sc.nextInt(); M = sc.nextInt(); int[] numArr = new int[N]; for (int i = 0; i < numArr.length; i++) {//숫자 입력받고 numArr[i] = sc.nextInt(); } for (int i = 0; i

import java.util.Scanner; public class Day6 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = 0; int sum = 0; int time = 0; int j = 0; System.out.print("자연수 입력 : "); N = sc.nextInt(); //N이 10이라 하면 10이 될 때까지 1부터 계속 연산, 10이 넘어간다면 2부터 다시 연산 while(j

import java.util.Scanner; public class Day5 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = 0, M = 0; //수의 개수, 나누어 떨어지는 숫자 int x = 0, y = 0;//쌍 (x, y) int time = 0; System.out.print("숫자 개수, 나누어 떨어지는 숫자 입력 : "); N = sc.nextInt();//5 입력시 M = sc.nextInt(); int[] numArr = new int[N+1];//6개 받을 수 있음 System.out.print("숫자" + N + "개 입력 : "); for (int i = 0; i < num..

내가 짠 코드 import java.util.Scanner; public class Day4 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = 0, m = 0;//n = NxN, m = 입력받는 횟수 int sum = 0; System.out.print("NxN의 N과 입력받을 횟수 입력 : "); n = sc.nextInt(); m = sc.nextInt(); int[][] numArr = new int[n][n]; for (int i = 0; i < n; i++) {//n만큼 입력 받기 for (int j = 0; j < n; j++) { numArr[i][j] = sc.nextInt(); } ..

- 위키백과 - 너비 우선 탐색(Breadth-first search, BFS)은 맹목적 탐색방법의 하나로 시작 정점을 방문한 후 시작 정점에 인접한 모든 정점들을 우선 방문하는 방법이다. 더 이상 방문하지 않은 정점이 없을 때까지 방문하지 않은 모든 정점들에 대해서도 너비 우선 검색을 적용한다. OPEN List는 큐를 사용해야만 레벨 순서대로 접근이 가능하다. 그래프의 너비 우선 탐색 알고리즘을 Java로 구현해보자. 우선 빈번히 사용 Node 클래스를 작성한다. Node.java public class Node { int info;//정점에 대응된 데이터 boolean visited;//방문 여부 List neighbours;//정점에 인접한 정점들의 연결 목록 public Node(int info..

내가 짠 코드 import java.util.Scanner; public class Day2 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int num = 0; double M = 0; double sum = 0; double avg = 0; System.out.print("과목 개수 : "); num = sc.nextInt(); double[] score = new double[num]; System.out.print("점수 입력 : "); for (int i = 0; i ..

Day1. 첫 백준 문제로 숫자의 합을 풀었다. import java.util.Scanner; public class Day1 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = 0, num = 0, sum = 0;//자릿수, 숫자, 합 System.out.print("자릿수 입력 : "); n = sc.nextInt(); System.out.print("숫자 입력 : "); num = sc.nextInt(); for (int i = 0; i < n; i++) { sum += num%10; num /= 10; } System.out.println(sum); } } 나는 이렇게 작성했고 결과도 잘 나왔..
- Total
- Today
- Yesterday
- 오블완
- SpringBoot
- 톰캣
- 이클립스
- 백준알고리즘
- MySQL
- 알고리즘
- dockerspring
- 웹스퀘어
- websquare
- tomcat
- docker컨테이너
- docker앱배포
- 백준
- docker
- 클라우드
- controller
- docker배포
- Apache
- 그리드
- google cloud run
- Spring
- 티스토리챌린지
- db
- 노드
- 트리
- Java
- 자바
- BigDecimal
- 백준자바
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |