일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 코딩테스트
- 이너클래스
- SpringBoot
- nextline()
- BufferedWriter
- 알고리즘
- A+B - 6
- 코딩은체육과목입니다
- 백준11021
- 연산자 우선순위
- 백준
- 백준10953
- 백준15552
- 그라운드시소
- Java
- 서버개발
- 10953
- 문자열메서드
- 논리 연산자
- BufferedReader
- 조건 연산자
- 11021
- 15552
- 인스턴스
- 비교 연산자
- A+B - 7
- 인스턴스화
- nextInt()
- 포맷팅
- 산술 연산자
- Today
- Total
목록Coding & Algorithm (15)
Coded by Juny
미래를 예측하는 이가 하루마다 바뀌는 물건의 시세를 알고 있다.테스트케이스 수, 시세 변동 날, 물건의 시세를 입력값으로 받는다.미래를 예측하는 이의 가장 큰 이득을 예상하라는 문제였다. 예시로, 입력값이 3 //테스트 케이스 수5 //케이스1의 시세 변동 총 날짜1 2 3 4 5 //케이스1의 5일동안의 시세 변동4 //케이스2의 시세 변동 총 날짜2 5 1 3 //케이스2의 4일동안의 시세 변동3 //케이스3의 시세 변동 총 날짜5 4 3 //케이스3의 3일동안의 시세 변동일 때, 출력값은 다음과 같다.#1 10 // 1일부터 4일까지 물건을 구매해서 가장 높은 5일에 판매하면 예상 최대 이익은 4, 3, 2, 1을 더해 총 10#2 5 // 3일의 5원때 2원으로 첫 째날에 구매해 3원의 이득과 ..
코딩 테스트를 준비하다가 무의식적으로 헷갈렸던 부분에 대해 확실하게 짚고자 작성해보려고 한다. nextLine()이 개행문자를 입력받으면 빈문자열로 입력되는 것을 알고는 있지만 계속 헷갈려서 gpt와 대화식으로 자세히 정리해보았다. Me : 5 1 2 2 1 2 3 1 2 4 1 2 5 10 7 1293 아아 입력값이 이렇게 들어왔을 때 맨 처음 5를 읽고나면 그다음 1을 읽을 땐 바로 nextInt()를 적어도 되지만 바로 nextLine()을 읽을 땐 개행문자를 읽어버려서 nextLine()을 두번 써줘야되는거지? GPT : 정확히 이해하셨습니다! 입력값이 다음과 같이 주어질 때:51 2 21 2 31 2 41 2 510 7 1293 입력 처리 과정첫 번째 입력 (5) 읽기int T = sc.n..
문제위의 그림과 같이 육각형으로 이루어진 벌집이 있다. 그림에서 보는 바와 같이 중앙의 방 1부터 시작해서 이웃하는 방에 돌아가면서 1씩 증가하는 번호를 주소로 매길 수 있다. 숫자 N이 주어졌을 때, 벌집의 중앙 1에서 N번 방까지 최소 개수의 방을 지나서 갈 때 몇 개의 방을 지나가는지(시작과 끝을 포함하여)를 계산하는 프로그램을 작성하시오. 예를 들면, 13까지는 3개, 58까지는 5개를 지난다.입력첫째 줄에 N(1 ≤ N ≤ 1,000,000,000)이 주어진다.출력입력으로 주어진 방까지 최소 개수의 방을 지나서 갈 때 몇 개의 방을 지나는지 출력한다. 제출import java.util.Scanner;public class B_0805 { public static void main(Strin..
문제가로, 세로의 크기가 각각 100인 정사각형 모양의 흰색 도화지가 있다. 이 도화지 위에 가로, 세로의 크기가 각각 10인 정사각형 모양의 검은색 색종이를 색종이의 변과 도화지의 변이 평행하도록 붙인다. 이러한 방식으로 색종이를 한 장 또는 여러 장 붙인 후 색종이가 붙은 검은 영역의 넓이를 구하는 프로그램을 작성하시오.예를 들어 흰색 도화지 위에 세 장의 검은색 색종이를 그림과 같은 모양으로 붙였다면 검은색 영역의 넓이는 260이 된다. 입력첫째 줄에 색종이의 수가 주어진다. 이어 둘째 줄부터 한 줄에 하나씩 색종이를 붙인 위치가 주어진다. 색종이를 붙인 위치는 두 개의 자연수로 주어지는데 첫 번째 자연수는 색종이의 왼쪽 변과 도화지의 왼쪽 변 사이의 거리이고, 두 번째 자연수는 색종이의 아래쪽 변..
문제아직 글을 모르는 영석이가 벽에 걸린 칠판에 자석이 붙어있는 글자들을 붙이는 장난감을 가지고 놀고 있다. 이 장난감에 있는 글자들은 영어 대문자 ‘A’부터 ‘Z’, 영어 소문자 ‘a’부터 ‘z’, 숫자 ‘0’부터 ‘9’이다. 영석이는 칠판에 글자들을 수평으로 일렬로 붙여서 단어를 만든다. 다시 그 아래쪽에 글자들을 붙여서 또 다른 단어를 만든다. 이런 식으로 다섯 개의 단어를 만든다. 아래 그림 1은 영석이가 칠판에 붙여 만든 단어들의 예이다. A A B C D Da f z z 0 9 1 2 1a 8 E W g 6P 5 h 3 k x한 줄의 단어는 글자들을 빈칸 없이 연속으로 나열해서 최대 15개의 글자들로 이루어진다. 또한 만들어진 다섯 개의 단어들의 글자 개수는 서로 다를 수 있다. 심심해진 영석..