Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
Tags
- Data Structure
- geometry
- Stack
- simulation
- SQL
- 자바
- array
- bit manipulation
- 코테
- Number Theory
- greedy
- database
- Counting
- Matrix
- 구현
- Method
- implement
- sorting
- Tree
- Binary Tree
- java
- 파이썬
- string
- two pointers
- Class
- 코딩테스트
- Binary Search
- hash table
- dynamic programming
- Math
Archives
- Today
- Total
코린이의 소소한 공부노트
[백준 온라인 저지] 11726. 2×n 타일링 본문
2*n 크기의 직사각형을 1*2, 2*1 타일로 채우려고 한다.
1. 입력
- 첫째 줄에 n이 주어진다. (1 ≤ n ≤ 1,000)
- n이 직사각형의 가로다.
2. 출력
- 첫째 줄에 2×n 크기의 직사각형을 채우는 방법의 수를 10,007로 나눈 나머지를 출력한다.
3. 예제
4. 코드
import java.util.*;
class Main{
public static void main(String[] args){
int n = new Scanner(System.in).nextInt();
if(n>2){
int[] d = new int[n];
d[0] = 1; d[1] = 2;
for(int i=2 ; i<n ; i++)
d[i] = (d[i-1] + d[i-2])%10007;
System.out.print(d[n-1]);
} else
System.out.print(n);
}
}
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[LeetCode/Easy] 897. Increasing Order Search Tree (0) | 2023.06.05 |
---|---|
[백준 온라인 저지] 11727. 2×n 타일링 2 (0) | 2023.06.01 |
[LeetCode/Easy] 892. Surface Area of 3D Shapes (0) | 2023.05.31 |
[LeetCode/Easy] 876. Middle of the Linked List (0) | 2023.05.31 |
[LeetCode/Easy] 830. Positions of Large Groups (0) | 2023.05.31 |