SWEA_1948) 날짜 계산기
SWEA
# D2
1948) 날짜 계산기 (19.10.04)
문제 링크 (SW Expert Academy)
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
32
33
34
35
36
37
38
39
40
41
42
|
import java.util.*;
import java.io.*;
public class Solution {
public static int day(int month) {
if(month==2) return 28;
else if(month==4 || month==6 || month==9 || month==11) return 30;
else return 31;
}
public static void main(String args[]) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
StringTokenizer tk;
int t = Integer.parseInt(br.readLine());
for(int i=1;i<=t;i++) {
tk = new StringTokenizer(br.readLine());
int startm = Integer.parseInt(tk.nextToken());
int startd = Integer.parseInt(tk.nextToken());
int endm = Integer.parseInt(tk.nextToken());
int endd = Integer.parseInt(tk.nextToken());
int ans = 0;
for(int p=startm+1;p<endm;p++) {
ans = ans+day(p);
}
ans = ans + day(startm)-startd+1;
if(startm!=endm) {
ans = ans + endd;
}
bw.write("#" + i + " " + ans + "\n");
}
bw.flush();
bw.close();
}
}
| cs |
댓글
댓글 쓰기