[jzoj 4786] 小a的强迫症 {组合计数} [jzoj 4787] 数格子 {矩阵乘法} [jzoj 4788] 序列 {贪心/桶}
(0+60+0)=60分, 第二题的矩阵乘法没有调试出来,咕咕了。
比赛代码
第二题60分状压
#include<cstdio>
#include<iostream>
#include<algorithm>
#define rr register
using namespace std
;
int n
,m
=4,lw
;
long long f
[1000005][1<<5];
bool ins
[1<<5]={1,0,0,1,0,0,0,0,0,1,0,0,1,0,0,1};
int main(){
while (cin
>>n
>>lw
&&n
){
f
[0][0]=1;
for(rr
int i
=1;i
<=n
;++i
)
for(rr
int j
=0;j
<1<<m
;++j
){
f
[i
][j
]=0;
for(rr
int k
=0;k
<1<<m
;++k
)
if ((j
&k
)==0&&ins
[j
|k
]) (f
[i
][j
]+=f
[i
-1][k
])%=lw
;
}
cout
<<f
[n
][0]<<endl
;
}
}