[BaekJoon] #10768 - 특별한 날 [Java][C++]
[BaekJoon] #10768 - 특별한 날 [Java][C++]
1. 아이디어
조건문을 활용해서 2월 18일 이전인지 당일인지 이후인지만 비교하면 된다.
2. 복잡도
| 접근 | 시간 | 공간 |
|---|---|---|
| 풀이 | $O(1)$ | $O(1)$ |
3. 코드
풀이 [Java][C++]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int m = Integer.parseInt(br.readLine());
int d = Integer.parseInt(br.readLine());
if (m < 2 || m == 2 && d < 18) {
System.out.println("Before");
} else if (m == 2 && d == 18) {
System.out.println("Special");
} else {
System.out.println("After");
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int m, d;
cin >> m >> d;
if (m < 2 || m == 2 && d < 18) {
cout << "Before";
} else if (m == 2 && d == 18) {
cout << "Special";
} else {
cout << "After";
}
}
This post is licensed under CC BY 4.0 by the author.