File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change 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+ */
You can’t perform that action at this time.
0 commit comments