BZOJ 1566: [NOI2009]管道取珠 另类DP
来源:互联网 发布:即时通信软件排行 编辑:程序博客网 时间:2024/05/25 19:56
题目:戳这里
题解:比较神的想法,因为最后答案是所有数的平方,那么我们就可以将问题转化一下,变成俩个人取数,两人拿出的结果相同的方案书目,YY一下就能证明这个转化的正确性,这就很好办了,瞎DP一下就行了。
#include<cstdio>#include<cstdlib>#include<ctime>#include<cmath>#include<cstring>#include<string>#include<algorithm>#include<iostream>#include<iomanip>using namespace std;char s1[600];char s2[600];int f[502][502][502];const int mod=1024523;int main(){ int n,m; scanf("%d%d",&n,&m); scanf("%s",s1+1); scanf("%s",s2+1); for(int i=1;i*2<=n;i++) swap(s1[i],s1[n-i+1]); for(int j=1;j*2<=m;j++) swap(s2[j],s2[m-j+1]); s1[n+1]='*'; s2[m+1]='^'; f[0][0][0]=1; for(int i=0;i<=n+m;i++) for(int j=0;j<=n && j<=i;j++) for(int k=0;k<=n && k<=i;k++) { int o1=j; int o2=i-j; int t1=k; int t2=i-k; if(o2>m || t2>m) continue; if(s1[o1+1]==s1[t1+1]) (f[o1+1][o2][t1+1]+=f[o1][o2][t1])%=mod; if(s2[o2+1]==s2[t2+1]) (f[o1][o2+1][t1]+=f[o1][o2][t1])%=mod; if(s1[o1+1]==s2[t2+1]) (f[o1+1][o2][t1]+=f[o1][o2][t1])%=mod; if(s2[o2+1]==s1[t1+1]) (f[o1][o2+1][t1+1]+=f[o1][o2][t1])%=mod; } cout<<f[n][m][n]<<endl; return 0;}
阅读全文
1 0
- BZOJ 1566: [NOI2009]管道取珠 另类DP
- 【BZOJ 1566】: 【NOI2009】管道取珠 另类DP
- Bzoj 1566: [NOI2009]管道取珠(DP)
- [平方的拆分 DP] BZOJ 1566 [NOI2009]管道取珠
- bzoj 1566: [NOI2009]管道取珠 (DP)
- [BZOJ 1566][NOI2009]管道取珠(DP)
- BZOJ 1566: [NOI2009]管道取珠
- BZOJ 1566: [NOI2009]管道取珠
- Bzoj 1566: [NOI2009]管道取珠(动态规划->神题)
- bzoj 1566: [NOI2009]管道取珠 动态规划
- BZOJ系列《[NOI2009]管道取珠》题解
- BZOJ P1566[NOI2009]管道取珠
- bzoj1566: [NOI2009]管道取珠 dp
- 【bzoj1566】【NOI2009】【管道取珠】【dp】
- 【noi2009】管道取珠
- [NOI2009]管道取珠
- 【bzoj 1566】管道取珠(DP)
- [bzoj1566][NOI2009]管道取珠
- 基于UDP Socket例子
- 在win7中运行hadoop码出现ClassCastException: class com.sun.jersey.core.impl.provider.entity.XMLJAXBElementPr
- Unity 抛物线,直线,Sine曲线等
- SpringBoot的actuator(执行器)常用的访问地址
- Java 对象
- BZOJ 1566: [NOI2009]管道取珠 另类DP
- python常用模块之os模块
- POJ 1899 Farmer Bill's Problem 笔记
- Qt中信号存在重载情况下的选择
- 数据库常见面试题
- Linux的SOCKET编程详解——非常叼
- 决策树算法学习笔记(二)
- 我的学习之路_第十六章_xml
- DICOM靶区头文件解析