QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#478501 | #8483. Count the Christmas Trees | rania__# | AC ✓ | 207ms | 199984kb | C++23 | 1.0kb | 2024-07-15 02:54:56 | 2024-07-15 02:54:57 |
Judging History
answer
#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef int in;
#define int long long
#define double long double
#define f first
#define s second
#define pb push_back
#define pp push
#define ceill(x,y) ((x/y)+(x%y!=0)*(x/abs(x)*y/abs(y)<0?0:1))
#define floorr(x,y) ((x/y)+(x%y!=0)*(x/abs(x)*y/abs(y)<0?-1:0))
#define YN(x) cout<<(x?"YES\n":"NO\n");
#define Yn(x) cout<<(x?"Yes\n":"No\n");
#define yn(x) cout<<(x?"yes\n":"no\n");
const int MAAX=1e18;
const int MOD=1e9+7;
const int MAX=1e9;
int dp[5010][5010];
int fun(int lft,int sum){
if(lft==0)
return sum==0;
if(sum<0)
return 0;
int &ret=dp[lft][sum];
if(~ret)
return ret;
return ret=(fun(lft-1,sum)+fun(lft-1,sum-1)+fun(lft-1,sum-2))%MOD;
}
in main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int tc=1;
// cin>>tc;
while(tc--){
memset(dp,-1,sizeof dp);
int n;
cin>>n;
int ans=1;
for(int i=1;i<n;i++){
ans*=fun(i,i+1);
ans%=MOD;
}
cout<<ans<<"\n";
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 7ms
memory: 199704kb
input:
3
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 7ms
memory: 199668kb
input:
4
output:
12
result:
ok 1 number(s): "12"
Test #3:
score: 0
Accepted
time: 4ms
memory: 199800kb
input:
1
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 3ms
memory: 199720kb
input:
2
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: 0
Accepted
time: 3ms
memory: 199664kb
input:
5
output:
192
result:
ok 1 number(s): "192"
Test #6:
score: 0
Accepted
time: 8ms
memory: 199668kb
input:
6
output:
8640
result:
ok 1 number(s): "8640"
Test #7:
score: 0
Accepted
time: 0ms
memory: 199636kb
input:
7
output:
1088640
result:
ok 1 number(s): "1088640"
Test #8:
score: 0
Accepted
time: 15ms
memory: 199712kb
input:
8
output:
388644480
result:
ok 1 number(s): "388644480"
Test #9:
score: 0
Accepted
time: 4ms
memory: 199636kb
input:
9
output:
862788922
result:
ok 1 number(s): "862788922"
Test #10:
score: 0
Accepted
time: 3ms
memory: 199776kb
input:
10
output:
127378698
result:
ok 1 number(s): "127378698"
Test #11:
score: 0
Accepted
time: 4ms
memory: 199736kb
input:
11
output:
612120859
result:
ok 1 number(s): "612120859"
Test #12:
score: 0
Accepted
time: 8ms
memory: 199648kb
input:
12
output:
524731288
result:
ok 1 number(s): "524731288"
Test #13:
score: 0
Accepted
time: 8ms
memory: 199800kb
input:
13
output:
703838332
result:
ok 1 number(s): "703838332"
Test #14:
score: 0
Accepted
time: 7ms
memory: 199648kb
input:
14
output:
71786008
result:
ok 1 number(s): "71786008"
Test #15:
score: 0
Accepted
time: 8ms
memory: 199664kb
input:
15
output:
346731212
result:
ok 1 number(s): "346731212"
Test #16:
score: 0
Accepted
time: 11ms
memory: 199708kb
input:
38
output:
865127889
result:
ok 1 number(s): "865127889"
Test #17:
score: 0
Accepted
time: 3ms
memory: 199768kb
input:
64
output:
808637919
result:
ok 1 number(s): "808637919"
Test #18:
score: 0
Accepted
time: 0ms
memory: 199796kb
input:
41
output:
468077351
result:
ok 1 number(s): "468077351"
Test #19:
score: 0
Accepted
time: 3ms
memory: 199712kb
input:
67
output:
87996243
result:
ok 1 number(s): "87996243"
Test #20:
score: 0
Accepted
time: 15ms
memory: 199708kb
input:
93
output:
249426735
result:
ok 1 number(s): "249426735"
Test #21:
score: 0
Accepted
time: 12ms
memory: 199776kb
input:
38
output:
865127889
result:
ok 1 number(s): "865127889"
Test #22:
score: 0
Accepted
time: 0ms
memory: 199712kb
input:
97
output:
478905528
result:
ok 1 number(s): "478905528"
Test #23:
score: 0
Accepted
time: 4ms
memory: 199792kb
input:
42
output:
35251093
result:
ok 1 number(s): "35251093"
Test #24:
score: 0
Accepted
time: 7ms
memory: 199776kb
input:
68
output:
741983464
result:
ok 1 number(s): "741983464"
Test #25:
score: 0
Accepted
time: 4ms
memory: 199644kb
input:
88
output:
774085871
result:
ok 1 number(s): "774085871"
Test #26:
score: 0
Accepted
time: 3ms
memory: 199796kb
input:
146
output:
463722912
result:
ok 1 number(s): "463722912"
Test #27:
score: 0
Accepted
time: 7ms
memory: 199756kb
input:
694
output:
524438366
result:
ok 1 number(s): "524438366"
Test #28:
score: 0
Accepted
time: 12ms
memory: 199652kb
input:
341
output:
240079920
result:
ok 1 number(s): "240079920"
Test #29:
score: 0
Accepted
time: 8ms
memory: 199732kb
input:
582
output:
971591101
result:
ok 1 number(s): "971591101"
Test #30:
score: 0
Accepted
time: 7ms
memory: 199720kb
input:
536
output:
135071031
result:
ok 1 number(s): "135071031"
Test #31:
score: 0
Accepted
time: 8ms
memory: 199820kb
input:
777
output:
715343919
result:
ok 1 number(s): "715343919"
Test #32:
score: 0
Accepted
time: 11ms
memory: 199660kb
input:
424
output:
640304651
result:
ok 1 number(s): "640304651"
Test #33:
score: 0
Accepted
time: 8ms
memory: 199816kb
input:
665
output:
674722290
result:
ok 1 number(s): "674722290"
Test #34:
score: 0
Accepted
time: 4ms
memory: 199732kb
input:
619
output:
318882692
result:
ok 1 number(s): "318882692"
Test #35:
score: 0
Accepted
time: 18ms
memory: 199636kb
input:
581
output:
596324753
result:
ok 1 number(s): "596324753"
Test #36:
score: 0
Accepted
time: 152ms
memory: 199836kb
input:
4325
output:
525474695
result:
ok 1 number(s): "525474695"
Test #37:
score: 0
Accepted
time: 180ms
memory: 199976kb
input:
4807
output:
564080175
result:
ok 1 number(s): "564080175"
Test #38:
score: 0
Accepted
time: 188ms
memory: 199920kb
input:
4908
output:
200443472
result:
ok 1 number(s): "200443472"
Test #39:
score: 0
Accepted
time: 156ms
memory: 199900kb
input:
4389
output:
875654571
result:
ok 1 number(s): "875654571"
Test #40:
score: 0
Accepted
time: 139ms
memory: 199756kb
input:
4109
output:
718073816
result:
ok 1 number(s): "718073816"
Test #41:
score: 0
Accepted
time: 180ms
memory: 199880kb
input:
4591
output:
513602210
result:
ok 1 number(s): "513602210"
Test #42:
score: 0
Accepted
time: 172ms
memory: 199848kb
input:
4692
output:
702018749
result:
ok 1 number(s): "702018749"
Test #43:
score: 0
Accepted
time: 183ms
memory: 199900kb
input:
4793
output:
966993722
result:
ok 1 number(s): "966993722"
Test #44:
score: 0
Accepted
time: 196ms
memory: 199852kb
input:
4894
output:
80095551
result:
ok 1 number(s): "80095551"
Test #45:
score: 0
Accepted
time: 171ms
memory: 199912kb
input:
4690
output:
716441253
result:
ok 1 number(s): "716441253"
Test #46:
score: 0
Accepted
time: 207ms
memory: 199984kb
input:
5000
output:
514043793
result:
ok 1 number(s): "514043793"
Extra Test:
score: 0
Extra Test Passed