[백준] 11727 2×n 타일링 2 c++
2022. 7. 4. 22:35ㆍ알고리즘/백준
728x90
11726 번 문제와 같이 직접 경우의수의 갯수를 구하고
점화식을 구하면 된다.
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
unsigned long long int arr[100001];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, m;
cin >> n;
arr[0] = 1;
arr[1] = 3;
for (int i = 2; i <= n + 1; i++) {
arr[i] = (arr[i - 2]*2 + arr[i - 1]) % 10007;
}
cout << arr[n - 1];
}
728x90
'알고리즘 > 백준' 카테고리의 다른 글
[백준] 잃어버린 괄호 1541 c++ (0) | 2022.07.06 |
---|---|
[백준] 11444 피보나치 수 6 (0) | 2022.07.05 |
[백준] 11726 2×n 타일링 c++ (0) | 2022.07.04 |
[백준] 9461 파도반 수열 c++ (2) | 2022.07.03 |
[백준] 11399 ATM c++ (0) | 2022.07.03 |