File tree Expand file tree Collapse file tree 2 files changed +59
-0
lines changed
Expand file tree Collapse file tree 2 files changed +59
-0
lines changed Original file line number Diff line number Diff line change 1+ # [ Silver II] 타일링 - 1793
2+
3+ [ 문제 링크] ( https://www.acmicpc.net/problem/1793 )
4+
5+ ### 성능 요약
6+
7+ 메모리: 15024 KB, 시간: 128 ms
8+
9+ ### 분류
10+
11+ 임의 정밀도 / 큰 수 연산, 다이나믹 프로그래밍
12+
13+ ### 제출 일자
14+
15+ 2024년 12월 20일 10:24:41
16+
17+ ### 문제 설명
18+
19+ <p >2×n 직사각형을 2×1과 2×2 타일로 채우는 방법의 수를 구하는 프로그램을 작성하시오.</p >
20+
21+ <p >아래 그림은 2×17 직사각형을 채운 한가지 예이다.</p >
22+
23+ <p style =" text-align : center ;" ><img alt =" " src =" https://www.acmicpc.net/upload/images/t2n2122.gif " style =" height :59px ; width :380px " ></p >
24+
25+ ### 입력
26+
27+ <p >입력은 여러 개의 테스트 케이스로 이루어져 있다. 각 테스트 케이스는 한 줄로 이루어져 있으며, 정수 n이 주어진다.</p >
28+
29+ ### 출력
30+
31+ <p >입력으로 주어지는 각각의 n마다, 2×n 직사각형을 채우는 방법의 수를 출력한다.</p >
32+
Original file line number Diff line number Diff line change 1+ import java .io .*;
2+ import java .math .BigInteger ;
3+ import java .util .*;
4+
5+ public class Main {
6+ public static void main (String [] args ) throws IOException {
7+ BufferedReader br = new BufferedReader (new InputStreamReader (System .in ));
8+
9+
10+ BigInteger [] dp = new BigInteger [251 ];
11+
12+
13+ dp [0 ] =BigInteger .valueOf (1 );
14+ dp [1 ] = BigInteger .valueOf (1 );
15+ dp [2 ] = BigInteger .valueOf (3 );
16+
17+ for (int i =3 ; i <251 ; i ++) {
18+ dp [i ] = dp [i -1 ].add (dp [i -2 ].multiply (new BigInteger ("2" )));
19+ }
20+
21+ String line = null ;
22+ while ((line =br .readLine ())!=null ) {
23+ int n = Integer .parseInt (line );
24+ System .out .println (dp [n ]);
25+ }
26+ }
27+ }
You can’t perform that action at this time.
0 commit comments