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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
using System.IO;
using System.Text;
using System.Linq;
using System.Reflection.PortableExecutable;
using System.Security.Cryptography;
namespace 연습장
{
internal class Program
{
static StringBuilder sb = new StringBuilder();
static void Main(string[] args)
{
using var reader = new StreamReader(Console.OpenStandardInput());
using var print = new StreamWriter(Console.OpenStandardOutput());
_11726_boj boj = new _11726_boj();
boj.boj_11726();
}
}
internal class _11726_boj
{
public void boj_11726()
{
int n = int.Parse(Console.ReadLine());
int[] dp = new int[n+1];
dp[0] = 0;
dp[1] = 1;
if (n == 1)
{
Console.WriteLine(dp[n]);
return;
}
dp[2] = 2;
if (n <= 2)
{
Console.WriteLine(dp[n]);
return;
}
for (int i = 3; i <= n; i++)
{
dp[i] = (dp[i - 1] + dp[i - 2]) % 10007 ;
}
Console.WriteLine(dp[n]);
}
}
}
|
cs |
3*n타일 문제를 풀던 생각에 사로잡혀 어떠한 규칙성을 찾아보려고 애를 써보았지만, 결국 전단계 + 전전단계 였다는 것을 알게되고 좌절한 나.
'다이나믹 프로그래밍 한접시' 카테고리의 다른 글
[백준] 2193번: 이찬수 [C#] (0) | 2024.04.28 |
---|---|
[백준] 11727번: 2*n 타일링 2 [C#] (0) | 2024.04.28 |
[백준] 1912번: 연속 합 [C#] (0) | 2024.04.27 |
[백준] 2748번: 피보나치 수 2 [C#] (0) | 2024.04.26 |
[백준] 1932번: 정수 삼각형 [C#] (1) | 2024.04.25 |