We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f87750d commit 5f567ccCopy full SHA for 5f567cc
src/backjoon/_9461.java
@@ -0,0 +1,44 @@
1
+package backjoon;
2
+// https://www.acmicpc.net/problem/9461
3
+
4
+import java.io.BufferedReader;
5
+import java.io.IOException;
6
+import java.io.InputStreamReader;
7
8
+public class _9461 {
9
+ // 1 ≤ N ≤ 100
10
+ public static Long[] seq = new Long[101];
11
12
+ public static void main(String[] args) throws IOException {
13
+ // memory 11504 runtime 88
14
+ BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
15
+ StringBuilder sb = new StringBuilder();
16
17
+ seq[0] = 0L;
18
+ seq[1] = 1L;
19
+ seq[2] = 1L;
20
+ seq[3] = 1L;
21
22
+ int N = Integer.parseInt(br.readLine());
23
+ for(int i=N; i>0; i--){
24
+ sb.append(padovan(Integer.parseInt(br.readLine()))).append('\n');
25
+ }
26
+ System.out.println(sb);
27
28
+ public static long padovan(int N) {
29
+ if(seq[N] == null) {
30
+ seq[N] = padovan(N - 2) + padovan(N - 3);
31
32
+ return seq[N];
33
34
+}
35
+/*
36
+INPUT
37
+2
38
+6
39
+12
40
41
+OUTPUT
42
+3
43
+16
44
+ */
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments