QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#736322 | #8483. Count the Christmas Trees | Bucketsmith# | AC ✓ | 73ms | 87500kb | C++20 | 705b | 2024-11-12 09:55:36 | 2024-11-12 09:55:36 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 5050, P = 1e9 + 7;
int dp[N][N];
void add(int &x, int y) {
x += y;
if(x >= P) x -= P;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
dp[0][0] = 1;
for(int i = 0; i + 1 < N; i ++) {
for(int j = 0; j <= min(i * 2, 5010); j ++) {
add(dp[i + 1][j], dp[i][j]);
add(dp[i + 1][j + 1], dp[i][j]);
add(dp[i + 1][j + 2], dp[i][j]);
}
}
int n, ans = 1;
cin >> n;
for(int i = 1; i < n; i ++)
ans = ans * (long long)dp[i][i + 1] % P;
cout << ans << "\n";
}
/*
3
5
3 5 1 4 2
4
1 2 4 3
5
3 5 2 1 4
*/
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 28ms
memory: 87460kb
input:
3
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 46ms
memory: 87448kb
input:
4
output:
12
result:
ok 1 number(s): "12"
Test #3:
score: 0
Accepted
time: 19ms
memory: 87432kb
input:
1
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 48ms
memory: 87436kb
input:
2
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: 0
Accepted
time: 16ms
memory: 87376kb
input:
5
output:
192
result:
ok 1 number(s): "192"
Test #6:
score: 0
Accepted
time: 73ms
memory: 87372kb
input:
6
output:
8640
result:
ok 1 number(s): "8640"
Test #7:
score: 0
Accepted
time: 23ms
memory: 87460kb
input:
7
output:
1088640
result:
ok 1 number(s): "1088640"
Test #8:
score: 0
Accepted
time: 27ms
memory: 87376kb
input:
8
output:
388644480
result:
ok 1 number(s): "388644480"
Test #9:
score: 0
Accepted
time: 56ms
memory: 87372kb
input:
9
output:
862788922
result:
ok 1 number(s): "862788922"
Test #10:
score: 0
Accepted
time: 51ms
memory: 87420kb
input:
10
output:
127378698
result:
ok 1 number(s): "127378698"
Test #11:
score: 0
Accepted
time: 32ms
memory: 87416kb
input:
11
output:
612120859
result:
ok 1 number(s): "612120859"
Test #12:
score: 0
Accepted
time: 24ms
memory: 87444kb
input:
12
output:
524731288
result:
ok 1 number(s): "524731288"
Test #13:
score: 0
Accepted
time: 36ms
memory: 87380kb
input:
13
output:
703838332
result:
ok 1 number(s): "703838332"
Test #14:
score: 0
Accepted
time: 48ms
memory: 87452kb
input:
14
output:
71786008
result:
ok 1 number(s): "71786008"
Test #15:
score: 0
Accepted
time: 39ms
memory: 87436kb
input:
15
output:
346731212
result:
ok 1 number(s): "346731212"
Test #16:
score: 0
Accepted
time: 56ms
memory: 87376kb
input:
38
output:
865127889
result:
ok 1 number(s): "865127889"
Test #17:
score: 0
Accepted
time: 44ms
memory: 87396kb
input:
64
output:
808637919
result:
ok 1 number(s): "808637919"
Test #18:
score: 0
Accepted
time: 48ms
memory: 87420kb
input:
41
output:
468077351
result:
ok 1 number(s): "468077351"
Test #19:
score: 0
Accepted
time: 47ms
memory: 87436kb
input:
67
output:
87996243
result:
ok 1 number(s): "87996243"
Test #20:
score: 0
Accepted
time: 31ms
memory: 87440kb
input:
93
output:
249426735
result:
ok 1 number(s): "249426735"
Test #21:
score: 0
Accepted
time: 39ms
memory: 87452kb
input:
38
output:
865127889
result:
ok 1 number(s): "865127889"
Test #22:
score: 0
Accepted
time: 56ms
memory: 87500kb
input:
97
output:
478905528
result:
ok 1 number(s): "478905528"
Test #23:
score: 0
Accepted
time: 44ms
memory: 87380kb
input:
42
output:
35251093
result:
ok 1 number(s): "35251093"
Test #24:
score: 0
Accepted
time: 35ms
memory: 87432kb
input:
68
output:
741983464
result:
ok 1 number(s): "741983464"
Test #25:
score: 0
Accepted
time: 53ms
memory: 87436kb
input:
88
output:
774085871
result:
ok 1 number(s): "774085871"
Test #26:
score: 0
Accepted
time: 24ms
memory: 87460kb
input:
146
output:
463722912
result:
ok 1 number(s): "463722912"
Test #27:
score: 0
Accepted
time: 48ms
memory: 87456kb
input:
694
output:
524438366
result:
ok 1 number(s): "524438366"
Test #28:
score: 0
Accepted
time: 43ms
memory: 87452kb
input:
341
output:
240079920
result:
ok 1 number(s): "240079920"
Test #29:
score: 0
Accepted
time: 36ms
memory: 87368kb
input:
582
output:
971591101
result:
ok 1 number(s): "971591101"
Test #30:
score: 0
Accepted
time: 19ms
memory: 87380kb
input:
536
output:
135071031
result:
ok 1 number(s): "135071031"
Test #31:
score: 0
Accepted
time: 50ms
memory: 87368kb
input:
777
output:
715343919
result:
ok 1 number(s): "715343919"
Test #32:
score: 0
Accepted
time: 24ms
memory: 87376kb
input:
424
output:
640304651
result:
ok 1 number(s): "640304651"
Test #33:
score: 0
Accepted
time: 46ms
memory: 87448kb
input:
665
output:
674722290
result:
ok 1 number(s): "674722290"
Test #34:
score: 0
Accepted
time: 52ms
memory: 87452kb
input:
619
output:
318882692
result:
ok 1 number(s): "318882692"
Test #35:
score: 0
Accepted
time: 39ms
memory: 87368kb
input:
581
output:
596324753
result:
ok 1 number(s): "596324753"
Test #36:
score: 0
Accepted
time: 40ms
memory: 87444kb
input:
4325
output:
525474695
result:
ok 1 number(s): "525474695"
Test #37:
score: 0
Accepted
time: 28ms
memory: 87500kb
input:
4807
output:
564080175
result:
ok 1 number(s): "564080175"
Test #38:
score: 0
Accepted
time: 30ms
memory: 87436kb
input:
4908
output:
200443472
result:
ok 1 number(s): "200443472"
Test #39:
score: 0
Accepted
time: 32ms
memory: 87368kb
input:
4389
output:
875654571
result:
ok 1 number(s): "875654571"
Test #40:
score: 0
Accepted
time: 40ms
memory: 87380kb
input:
4109
output:
718073816
result:
ok 1 number(s): "718073816"
Test #41:
score: 0
Accepted
time: 36ms
memory: 87496kb
input:
4591
output:
513602210
result:
ok 1 number(s): "513602210"
Test #42:
score: 0
Accepted
time: 24ms
memory: 87436kb
input:
4692
output:
702018749
result:
ok 1 number(s): "702018749"
Test #43:
score: 0
Accepted
time: 32ms
memory: 87496kb
input:
4793
output:
966993722
result:
ok 1 number(s): "966993722"
Test #44:
score: 0
Accepted
time: 24ms
memory: 87488kb
input:
4894
output:
80095551
result:
ok 1 number(s): "80095551"
Test #45:
score: 0
Accepted
time: 43ms
memory: 87376kb
input:
4690
output:
716441253
result:
ok 1 number(s): "716441253"
Test #46:
score: 0
Accepted
time: 31ms
memory: 87372kb
input:
5000
output:
514043793
result:
ok 1 number(s): "514043793"
Extra Test:
score: 0
Extra Test Passed