반응형
Notice
Recent Posts
Recent Comments
Link
지구정복
[DP] 백준 - 타일 장식물 본문
728x90
반응형
-자바
package dp;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
public class TileDeco {
private static BufferedWriter bw =
new BufferedWriter( new OutputStreamWriter(System.out));
private static int n;
private static long[] d;
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
n = Integer.parseInt( br.readLine() );
d = new long[81];
d[1] = 4;
d[2] = 6;
for( int i=3; i<=n; i++ ) d[i] = d[i-2] + d[i-1];
bw.write( d[n] + "\n" );
bw.flush();
bw.close();
br.close();
}
}
-파이썬
n = int(input())
d = [0] * 81
d[1] = 4
d[2] = 6
for i in range( 3, n+1 ):
d[i] = d[i-2] + d[i-1]
print( d[n] )
728x90
반응형
'데이터 엔지니어링 정복 > Algorithm' 카테고리의 다른 글
[DP] 백준 - 다리놓기 (0) | 2021.07.17 |
---|---|
[DP] 백준 - 파스칼의 삼각형 (0) | 2021.07.16 |
[DP] 백준 - BABBA (0) | 2021.07.16 |
[DP] 백준 - 퇴사2 (0) | 2021.07.16 |
[DP] 백준 - 설탕배달 (0) | 2021.07.15 |
Comments