ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#212089 | #3815. 种树 | anruifeng | 100 | 2ms | 1228kb | C++ | 587b | 2024-10-13 11:07:52 | 2024-10-13 12:56:01 |
answer
#include<bits/stdc++.h>
using namespace std;
int n,m,k,num[70000],s[70000],s0,s1,s2;
long long f[20][70000][10],ans,g;
int main()
{
cin>>n>>m>>k;
for(int i=0;i<(1<<m);i++)
{
if(i&(i<<1)) continue;
g=0;
for(int j=0;j<m;j++) if(i&(1<<j)) g++;
s[++s0]=i;
num[s0]=g;
}
f[0][1][0]=1;
for(int i=1;i<=n;i++)
for(int j=1;j<=s0;j++)
for(int kk=0;kk<=k;kk++)
{
if(kk>=num[j])
{
for(int t=1;t<=s0;t++) if(!(s[t]&s[j])) f[i][j][kk]+=f[i-1][t][kk-num[j]];
}
}
for(int i=1;i<=s0;i++) ans+=f[n][i][k];
cout<<ans;
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 0ms
memory: 1216kb
input:
2 2 1
output:
4
result:
ok 1 number(s): "4"
Test #2:
score: 10
Accepted
time: 1ms
memory: 1212kb
input:
2 3 2
output:
8
result:
ok 1 number(s): "8"
Test #3:
score: 10
Accepted
time: 1ms
memory: 1224kb
input:
4 4 2
output:
96
result:
ok 1 number(s): "96"
Test #4:
score: 10
Accepted
time: 0ms
memory: 1224kb
input:
4 4 5
output:
304
result:
ok 1 number(s): "304"
Test #5:
score: 10
Accepted
time: 0ms
memory: 1216kb
input:
3 4 3
output:
84
result:
ok 1 number(s): "84"
Test #6:
score: 10
Accepted
time: 0ms
memory: 1220kb
input:
3 5 2
output:
83
result:
ok 1 number(s): "83"
Test #7:
score: 10
Accepted
time: 0ms
memory: 1216kb
input:
3 5 3
output:
215
result:
ok 1 number(s): "215"
Test #8:
score: 10
Accepted
time: 0ms
memory: 1220kb
input:
3 5 4
output:
276
result:
ok 1 number(s): "276"
Test #9:
score: 10
Accepted
time: 0ms
memory: 1220kb
input:
3 5 5
output:
174
result:
ok 1 number(s): "174"
Test #10:
score: 10
Accepted
time: 0ms
memory: 1228kb
input:
4 3 5
output:
18
result:
ok 1 number(s): "18"
Extra Test:
score: 0
Extra Test Passed