BZOJ1090(SCOI2003)[字符串折叠]--区间DP
来源:互联网 发布:教程网网站源码php 编辑:程序博客网 时间:2024/05/22 23:12
【链接】
bzoj1090
【解题报告】
区间DP
定义
不难得出
如果
#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int maxn=105;int f[maxn][maxn];char s[maxn];int Getlen(int x) {int len=0; while (x) len++,x/=10; return len;}bool Check(int l,int r,int L,int R){ if ((R-L+1)%(r-l+1)!=0) return 0; for (int i=L; i<=R; i++) if (s[i]!=s[(i-L)%(r-l+1)+l]) return 0; return 1;}int DP(int l,int r){ if (l==r) return 1; if (f[l][r]) return f[l][r]; f[l][r]=r-l+1; for (int i=l; i<=r; i++) { int L=DP(l,i),R=DP(i+1,r); f[l][r]=min(f[l][r],L+R); if (Check(l,i,i+1,r)) f[l][r]=min(f[l][r],L+2+Getlen((r-i)/(i-l+1)+1)); } return f[l][r];}int main(){ freopen("1090.in","r",stdin); freopen("1090.out","w",stdout); scanf("%s",s+1); memset(f,0,sizeof(f)); printf("%d",DP(1,strlen(s+1))); return 0;}
阅读全文
0 0
- 【BZOJ1090】[SCOI2003]字符串折叠【区间DP】
- BZOJ1090: [SCOI2003]字符串折叠 区间DP
- 【BZOJ1090】【SCOI2003】字符串折叠 {区间dp}
- BZOJ1090(SCOI2003)[字符串折叠]--区间DP
- bzoj1090: [SCOI2003]字符串折叠 dp
- [DP] BZOJ1090: [SCOI2003]字符串折叠
- 【BZOJ1090 || SCOI2003】字符串折叠
- bzoj1090: [SCOI2003]字符串折叠
- bzoj1090[SCOI2003]字符串折叠
- bzoj1090 [SCOI2003]字符串折叠
- bzoj1090 [SCOI2003]字符串折叠
- BZOJ1090 [SCOI2003]字符串折叠
- 【bzoj1090】[SCOI2003]字符串折叠
- bzoj1090(区间dp,字符串折叠问题)
- BZOJ 1090 [SCOI2003]字符串折叠 区间DP
- 1090: [SCOI2003]字符串折叠 区间DP
- 【bzoj 1090】[SCOI2003]字符串折叠 区间dp
- [BZOJ]1090: [SCOI2003]字符串折叠 区间DP
- 后端_第八课_数据库
- C#中Invoke的用法
- 基于java的百度语音识别示例
- mac/linux conda:command no found
- 1032. 挖掘机技术哪家强(20) PAT乙级真题
- BZOJ1090(SCOI2003)[字符串折叠]--区间DP
- CodeForces
- 1052. 卖个萌 (20)
- 机器学习实战 Kmeans
- 关于操作系统进程
- 深入理解 Neutron -- OpenStack 网络实现:VXLAN 模式
- ubuntu开机自动挂载硬盘分区
- 守护进程中/dev/null
- [转载]字符编码