首页 技术 正文
技术 2022年11月20日
0 收藏 647 点赞 4,868 浏览 1329 个字

链接

这题第一想法是矩阵,不过范围太大了,然后就没有思路了。。

之后看到群里的解法,行和列可以分着走,两者是互不影响的,这样就把二维转换成了一维,直接dp求出就可以了。

然后再组合相乘一下。

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 1010
#define LL __int64
#define INF 0xfffffff
#define mod 9999991
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
LL dp1[N][N],dp2[N][N];
LL o[][N];
LL c[N][N];
void init()
{
c[][] = ;
for(int i = ;i < ;i++)
{
c[i][] = c[i][i] = ;
for(int j = ; j < i;j++)
{
c[i][j] = c[i-][j] + c[i-][j-];
if(c[i][j] >= mod)
c[i][j] -= mod;
}
}
}
int main()
{
int n,m,t,k,x,y;
int i,j;
int kk = ;
init();
cin>>t;
while(t--)
{
memset(dp1,,sizeof(dp1));
memset(dp2,,sizeof(dp2));
memset(o,,sizeof(o));
scanf("%d%d%d%d%d",&n,&m,&k,&x,&y);
dp1[][x] = ;o[][]+=;
dp2[][y] = ;o[][]+=;
for(i = ;i <=k ;i++)
for(j = ; j <=n ;j++)
{
if(j>) dp1[i][j]=(dp1[i][j]+dp1[i-][j-])%mod;
dp1[i][j]+=dp1[i-][j-];dp1[i][j]%=mod;
dp1[i][j]+=dp1[i-][j+];dp1[i][j]%=mod;
dp1[i][j]+=dp1[i-][j+];dp1[i][j]%=mod;
o[][i]+=dp1[i][j];
o[][i]%=mod;
}
for(i = ; i <=k ;i++)
for(j = ; j <= m ;j++)
{
if(j>) dp2[i][j]+=dp2[i-][j-];dp2[i][j]%=mod;
dp2[i][j]+=dp2[i-][j-];dp2[i][j]%=mod;
dp2[i][j]+=dp2[i-][j+];dp2[i][j]%=mod;
dp2[i][j]+=dp2[i-][j+];dp2[i][j]%=mod;
o[][i]+=dp2[i][j];
o[][i]%=mod;
} LL ans=;
for(i = ; i <= k; i++)
{
ans =(ans+c[k][i]*o[][i]%mod*o[][k-i]%mod)%mod;
}
printf("Case #%d:\n",++kk);
cout<<ans<<endl;
}
return ;
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,910
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,435
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,250
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,061
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,693
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,731