
두 문제는 푸는 과정이 비슷하여 같이 작성한다. 두 문제 모두 세 자리 수의 각각 백의 자리, 십의 자리, 일의 자리 숫자를 구해야 한다. [2588 곱셈] public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = 0; int a = 0; n = sc.nextInt(); a = sc.nextInt(); int b = a / 100;//100의 자리 int c = a % 100 / 10;//10의 자리 int d = a % 10;//1의 자리 System.out.println(n*d); System.out.println(n*c); System.out.println(n*b); ..

첫 번째 정수 a는 b보다 작아야 한다. a가 1이라면 그냥 a와 b를 곱하면 된다. b가 a로 나누어 떨어진다면 그냥 b가 최소공배수이다. 그것이 아니라면, 작업을 수행해야 한다. d를 for문의 i처럼 활용하였다. 정수 b에 d를 곱해보면서, a와 나누어 떨어지는 수를 찾는 것이다. for문 보다는 while문을 사용하기에 적절하다. 무한루프 while문에서 최소공배수 c를 찾으면 탈출하게 된다. public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = 0;//첫 번째 정수 long b = 0;//두 번째 정수 long c = 0;//최소공배수 int d = 2;//i ..

나머지를 저장하는 일 까지는 수월히 했다가... 서로 다른 값의 수를 구하라 했을 때 읭..? 했다. 고민하다가 저번에 배운 중복을 허용하지 않는 HashSet이 생각나서 응용해 보기로 했다. import java.util.HashSet; import java.util.Scanner; import java.util.Set; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] a = new int[10]; Set nSet = new HashSet(); for (int i = 0; i < a.length; i++) { a[i] = sc.nextInt(); nSet.add(a[..

처음 짠 코드는 시간복잡도가 O(n * m) 이라 시간 초과 당했다... 아래가 처음 코드 public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = 0, m = 0; int a = 0; n = sc.nextInt(); int[] nArr = new int [n]; for (int i = 0; i < nArr.length; i++) { nArr[i] = sc.nextInt(); } m = sc.nextInt(); int[] mArr = new int [m]; for (int i = 0; i < mArr.length; i++) { mArr[i] = sc.nextInt(); } ..

오랜만에 다시 돌아온 백준 문제풀이... 몸풀기로 가볍게 실버부터 도전했다ㅋㅋ 너무 오랜만에 해서 자바로 제출할때 클래스 이름 Main으로 바꾸는 것도 까먹었다. 컴파일 에러가 주르륵...🫨 처음에는 문제를 제대로 안 읽고 해서 그냥 ' ( ' 랑 ' ) ' 개수만 일치하면 되는 줄 알았다. 그런데 )( 이런 것은 개수가 같지만 괄호로 치지 않는다더라..😑 내 코드 public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int num = 0; int a = 0; int b = 0; num = sc.nextInt(); String[] c = new String[num]; for (int ..

import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] n = new int[5]; int sum = 0; for (int i = 0; i < 5; i++) { n[i] = sc.nextInt(); sum += n[i]; } System.out.println(sum); } } 브론즈5짜리 문제라 그런지 역시 너무 쉽다 ㅎㅎ

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 ..
- Total
- Today
- Yesterday
- db
- controller
- 클라우드
- 노드
- 그리드
- 이클립스
- docker배포
- 알고리즘
- MySQL
- google cloud run
- 티스토리챌린지
- docker컨테이너
- 오블완
- 톰캣
- dockerspring
- Java
- SpringBoot
- 웹스퀘어
- Apache
- 백준자바
- Spring
- 트리
- 백준
- docker앱배포
- BigDecimal
- 백준알고리즘
- tomcat
- 자바
- websquare
- docker
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |