Skip to content

Commit 602df31

Browse files
committed
[D2] Title: 날짜 계산기, Time: 83 ms, Memory: 24,576 KB -BaekjoonHub
1 parent 2f41161 commit 602df31

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# [D2] 날짜 계산기 - 1948
2+
3+
[문제 링크](https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV5PnnU6AOsDFAUq)
4+
5+
### 성능 요약
6+
7+
메모리: 24,576 KB, 시간: 83 ms, 코드길이: 1,525 Bytes
8+
9+
### 제출 일자
10+
11+
2025-10-23 19:05
12+
13+
14+
15+
> 출처: SW Expert Academy, https://swexpertacademy.com/main/code/problem/problemList.do
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import java.util.*;
2+
import java.io.*;
3+
4+
class Solution
5+
{
6+
public static void main(String args[]) throws IOException
7+
{
8+
Map<Integer, Integer> map = new HashMap<>();
9+
map.put(1,31);
10+
map.put(2,28);
11+
map.put(3,31);
12+
map.put(4,30);
13+
map.put(5,31);
14+
map.put(6,30);
15+
map.put(7,31);
16+
map.put(8,31);
17+
map.put(9,30);
18+
map.put(10,31);
19+
map.put(11,30);
20+
map.put(12,31);
21+
22+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
23+
StringBuilder sb = new StringBuilder();
24+
int T = Integer.parseInt(br.readLine()); //테케 갯수
25+
26+
for(int i = 1; i<=T; i++){
27+
StringTokenizer st = new StringTokenizer(br.readLine());
28+
int beforeMonth = Integer.parseInt(st.nextToken());
29+
int beforeDate = Integer.parseInt(st.nextToken());
30+
int afterMonth = Integer.parseInt(st.nextToken());
31+
int afterDate = Integer.parseInt(st.nextToken());
32+
33+
int count = 0;
34+
35+
if(beforeMonth == afterMonth){
36+
count = afterDate - beforeDate + 1;
37+
}else{
38+
for(int j=beforeMonth+1; j<afterMonth; j++){
39+
count += map.get(j);
40+
}
41+
42+
count+=map.get(beforeMonth)-beforeDate+1;
43+
count+=afterDate;
44+
}
45+
46+
sb.append("#"+i+" "+count+"\n");
47+
}
48+
System.out.println(sb);
49+
}
50+
}

0 commit comments

Comments
 (0)