이번 주에 늦은 연봉협상이 있었다. 게다가 운영 서버 반영 일정도 있었다. 너무 바쁜 한 주 였다. 그래도 할 건 해야지... 하루 늦은 회고를 써본다.
import java.io.*;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
public class Main {
public static void main(String[] args) {
try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
Solution s = new Solution();
System.out.println(s.solution(getInput(br), getInput(br)));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private static int[] getInput(BufferedReader br) throws IOException {
String[] tokens = br.readLine().split(" ");
int[] input = new int[3];
input[0] = Integer.parseInt(tokens[0]);
input[1] = Integer.parseInt(tokens[1]);
input[2] = Integer.parseInt(tokens[2]);
return input;
}
}
class Solution {
public String solution(int[] startDate, int[] endDate) {
LocalDate today = LocalDate.of(startDate[0], startDate[1], startDate[2]);
LocalDate targetDay = LocalDate.of(endDate[0], endDate[1], endDate[2]);
return getAnswer(today, targetDay);
}
private String getAnswer(LocalDate today, LocalDate targetDay) {
if(targetDay.isAfter(today.plusYears(1000)) || targetDay.isEqual(today.plusYears(1000))) return "gg";
return "D-" + ChronoUnit.DAYS.between(today, targetDay);
}
}
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
Solution s = new Solution();
System.out.println(s.solution(getInput(br)));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private static int[] getInput(BufferedReader br) throws IOException {
int len = Integer.parseInt(br.readLine());
int[] arr = new int[len];
for (int i = 0; i < len; i++) {
arr[i] = Integer.parseInt(br.readLine());
}
return arr;
}
}
class Solution {
public String solution(int[] arr) {
List<Long> field = getField(arr);
StringBuilder answer = new StringBuilder();
for(int i : arr) answer.append(field.get(i)).append("\n");
return answer.toString();
}
private List<Long> getField(int[] arr) {
int limit = getMaxElem(arr);
Long[] defaultValues = {0L, 1L, 1L, 1L, 2L, 2L, 3L, 4L, 5L, 7L, 9L};
List<Long> lst = new ArrayList<>();
for(long i : defaultValues) lst.add(i);
for (int i = defaultValues.length - 1; i < limit + 1; i++) {
lst.add(lst.get(i) + lst.get(i - 4));
}
return lst;
}
private int getMaxElem(int[] arr) {
int max = 0;
for (int i : arr) {
max = Math.max(max, i);
}
return max;
}
}