QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#16845 | #2153. HILO | JohnAlfnov | 100 ✓ | 88ms | 3908kb | C++11 | 644b | 2021-12-25 12:42:10 | 2022-05-04 12:01:24 |
Judging History
answer
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int f[2][2][5005],g[2][2][5005];
int main(){
int n,x,b=0;
scanf("%d%d",&n,&x);
f[b^1][1][x]=1;
for(int h=n-1;h>=0;--h,b^=1)for(int j=min(x,h);j>=0;--j){
f[b][1][j]=(1ll*(h+1!=n)*f[b^1][1][j+1]*(h+1)+f[b^1][1][j+1]+f[b^1][0][j+1])%mod;
g[b][1][j]=(1ll*(h+1!=n)*g[b^1][1][j+1]*(h+1)+g[b^1][1][j+1]+g[b^1][0][j+1]+f[b^1][0][j+1])%mod;
f[b][0][j]=(1ll*(h+1!=n)*f[b^1][0][j]*(h+1)+f[b^1][1][j]+f[b^1][0][j])%mod;
g[b][0][j]=(1ll*(h+1!=n)*g[b^1][0][j]*(h+1)+g[b^1][1][j]+g[b^1][0][j])%mod;
}
printf("%d\n",(g[b^1][0][0]+g[b^1][1][0])%mod);
return 0;
}
詳細信息
Test #1:
score: 3.84615
Accepted
time: 3ms
memory: 3812kb
input:
4 2
output:
17
result:
ok 1 number(s): "17"
Test #2:
score: 3.84615
Accepted
time: 3ms
memory: 3808kb
input:
60 10
output:
508859913
result:
ok 1 number(s): "508859913"
Test #3:
score: 3.84615
Accepted
time: 2ms
memory: 3820kb
input:
36 2
output:
653172943
result:
ok 1 number(s): "653172943"
Test #4:
score: 3.84615
Accepted
time: 1ms
memory: 3756kb
input:
38 12
output:
877759561
result:
ok 1 number(s): "877759561"
Test #5:
score: 3.84615
Accepted
time: 2ms
memory: 3784kb
input:
40 22
output:
587738552
result:
ok 1 number(s): "587738552"
Test #6:
score: 3.84615
Accepted
time: 1ms
memory: 3712kb
input:
42 9
output:
142300060
result:
ok 1 number(s): "142300060"
Test #7:
score: 3.84615
Accepted
time: 0ms
memory: 3784kb
input:
44 42
output:
194449602
result:
ok 1 number(s): "194449602"
Test #8:
score: 3.84615
Accepted
time: 2ms
memory: 3804kb
input:
46 41
output:
996298696
result:
ok 1 number(s): "996298696"
Test #9:
score: 3.84615
Accepted
time: 3ms
memory: 3804kb
input:
48 16
output:
933315069
result:
ok 1 number(s): "933315069"
Test #10:
score: 3.84615
Accepted
time: 2ms
memory: 3808kb
input:
50 1
output:
592235889
result:
ok 1 number(s): "592235889"
Test #11:
score: 3.84615
Accepted
time: 2ms
memory: 3800kb
input:
106 25
output:
370147128
result:
ok 1 number(s): "370147128"
Test #12:
score: 3.84615
Accepted
time: 3ms
memory: 3812kb
input:
162 125
output:
588210522
result:
ok 1 number(s): "588210522"
Test #13:
score: 3.84615
Accepted
time: 0ms
memory: 3832kb
input:
218 196
output:
722904144
result:
ok 1 number(s): "722904144"
Test #14:
score: 3.84615
Accepted
time: 1ms
memory: 3872kb
input:
275 77
output:
201201377
result:
ok 1 number(s): "201201377"
Test #15:
score: 3.84615
Accepted
time: 1ms
memory: 3784kb
input:
331 195
output:
105599195
result:
ok 1 number(s): "105599195"
Test #16:
score: 3.84615
Accepted
time: 0ms
memory: 3756kb
input:
387 160
output:
51654417
result:
ok 1 number(s): "51654417"
Test #17:
score: 3.84615
Accepted
time: 3ms
memory: 3832kb
input:
443 407
output:
973597938
result:
ok 1 number(s): "973597938"
Test #18:
score: 3.84615
Accepted
time: 3ms
memory: 3832kb
input:
500 196
output:
279036314
result:
ok 1 number(s): "279036314"
Test #19:
score: 3.84615
Accepted
time: 55ms
memory: 3900kb
input:
4944 2238
output:
373098474
result:
ok 1 number(s): "373098474"
Test #20:
score: 3.84615
Accepted
time: 75ms
memory: 3904kb
input:
4952 3750
output:
127862445
result:
ok 1 number(s): "127862445"
Test #21:
score: 3.84615
Accepted
time: 88ms
memory: 3888kb
input:
4960 2465
output:
524400159
result:
ok 1 number(s): "524400159"
Test #22:
score: 3.84615
Accepted
time: 75ms
memory: 3908kb
input:
4968 3013
output:
429923833
result:
ok 1 number(s): "429923833"
Test #23:
score: 3.84615
Accepted
time: 55ms
memory: 3844kb
input:
4976 2108
output:
909616241
result:
ok 1 number(s): "909616241"
Test #24:
score: 3.84615
Accepted
time: 47ms
memory: 3832kb
input:
4984 1656
output:
572267695
result:
ok 1 number(s): "572267695"
Test #25:
score: 3.84615
Accepted
time: 70ms
memory: 3900kb
input:
4992 3695
output:
824711289
result:
ok 1 number(s): "824711289"
Test #26:
score: 3.84615
Accepted
time: 9ms
memory: 3808kb
input:
5000 207
output:
765133070
result:
ok 1 number(s): "765133070"