-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproblem3174.cpp
57 lines (49 loc) · 1011 Bytes
/
problem3174.cpp
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
54
55
56
57
#include <stdio.h>
typedef unsigned long long llu;
const int mod = 1000003;
llu dp[1000], DelNums[1000];
int bpoint = 0;
void Delannoy(int n)
{
int endPoint = bpoint + n;
for (int i = 0; i < n; i++)
{
int temp = dp[0];
dp[0] = 1;
int j = 0;
while (j < bpoint + i)
{
if (j > 0)
{
int temp1 = dp[j];
dp[j] = dp[j - 1] + dp[j] + temp;
dp[j] %= mod;
temp = temp1;
}
j++;
}
if (j == 0)
{
DelNums[j] = dp[j];
continue;
}
dp[j] = 2 * dp[j - 1] + DelNums[j - 1];
dp[j] %= mod;
DelNums[j] = dp[j];
}
}
int main()
{
int t, n;
scanf("%d", &t);
for (int i = 0; i < t; i++)
{
scanf("%d", &n);
if (n > bpoint)
{
Delannoy(n - bpoint);
bpoint = n;
}
printf("%llu\n", DelNums[n - 1]);
}
}