import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
StringBuilder sb = new StringBuilder();
long[] wave = new long[101];
wave[1] = 1;
wave[2] = 1;
wave[3] = 1;
wave[4] = 2;
wave[5] = 2;
int index = 5;
int T = Integer.parseInt(br.readLine());
for(int i = 0; i < T; i++) {
int n = Integer.parseInt(br.readLine());
if(wave[n] == 0) {
while(index < n) {
wave[++index] = wave[index-1] + wave[index-5];
}
}
sb.append(wave[n]).append('\n');
}
bw.write(sb.toString());
bw.close();
br.close();
}
}
반응형
'Algorithm > 백준' 카테고리의 다른 글
[백준] 1로 만들기 1463번 - java (0) | 2021.11.18 |
---|---|
[백준] RGB거리 1149번 -java (0) | 2021.11.07 |
[백준] 신나는 함수 실행 - java (0) | 2021.11.06 |
[백준] N과 M (4) 15652번 - java (0) | 2021.11.06 |
[백준] N과 M (3) 15651번 - java (0) | 2021.11.06 |