poj 1080
来源:互联网 发布:地下城老是网络中断 编辑:程序博客网 时间:2024/05/22 14:20
题目:
戳
题意:
不复制了。。。大家自己找吧。。
分析:
他是一到dp。
然后,我完全不知道dp方程长什么样子。。。
说是跟最长公共子序列有关系。
那就是:
s1[i]=s2[j] dp[i][j]+1 一类神马的。
那你想啊:
这是要计分啊。所以把它加上分数不就好了吗。
dp方程建 代码。。
dp题还是要多写啊。。
#include<cstdio>#include<algorithm>#include<cstring>#include<iostream> using namespace std;//by mars_chint t,len1,len2;char s1[105],s2[105];int dp[105][105];int score[5][5]={{5,-1,-2,-1,-3},{-1,5,-3,-2,-4},{-2,-3,5,-2,-2},{-1,-2,-2,5,-1},{-3,-4,-2,-1,0}};int rr(char c){ if(c == 'A') return 0; else if(c == 'C') return 1; else if(c == 'G') return 2; else if(c == 'T') return 3; else return 4;}int main(){ scanf("%d",&t); while(t--) { memset(dp,0,sizeof(dp)); scanf("%d %s%d %s",&len1,s1,&len2,s2); for(int i=1;i<=len1;i++) { dp[i][0]=dp[i-1][0]+score[rr(s1[i-1])][4]; } for(int i=1;i<=len2;i++) { dp[0][i]=dp[0][i-1]+score[4][rr(s2[i-1])]; } // cout<<"lalala"<<endl; for(int i=1;i<=len1;i++) { for(int j=1;j<=len2;j++) { if(s1[i-1] == s2[j-1]) dp[i][j]=dp[i-1][j-1]+5; else { dp[i][j]=max(dp[i][j-1]+score[4][rr(s2[j-1])],max(dp[i-1][j]+score[rr(s1[i-1])][4],dp[i-1][j-1]+score[rr(s1[i-1])][rr(s2[j-1])])); } } } printf("%d\n",dp[len1][len2]); } return 0;}
别因为数学卷子影响你的心情。
就像天气好一样你因该开心。
1 0
- POJ 1080
- POJ 1080
- POJ 1080
- poj 1080
- poj 1080
- poj 1080
- poj 1080
- POJ 1080
- poj-1080
- poj 1080
- poj 1080
- POJ 1080
- poj 1080
- POJ 1080
- poj 1080
- POJ 1080 LCS扩展!
- 【DP】 POJ 1080
- POJ 1080 (DP)
- Renesas-入门
- 空格替换
- fork wait
- scroller与scrollto
- Ubuntu 14.04 LTS下为终端设置代理
- poj 1080
- Java设计模式——装饰者设计模式
- Codeforces Round #352 (Div. 2)
- win10 uwp 判断文件存在
- git warning: LF will be replaced by CRLF in 解决办法
- ZOJ 1649 BFS
- 教你如何迅速秒杀掉:99%的海量数据处理面试题
- 【css】所有的a标签设置为新窗口打开【原创】
- 设计模式之代理模式