Uva 10617 Again Palindromes
2013-08-23 21:12
363 查看
CLICK ME
问一个字符串的子序列是回文串的个数;
dp
问一个字符串的子序列是回文串的个数;
dp
#include<cstdio> #include<cstring> #include<iostream> using namespace std; char s[70]; long long dp[70][70]; int main() { int cas; //freopen("input.txt","r",stdin); scanf("%d",&cas); while(cas--){ scanf("%s",s+1); int n=strlen(s+1); memset(dp,0,sizeof dp); for(int k=0;k<n;k++) { for(int l=1;l<=n;l++) { int r=l+k;if(r>n) break; if(s[l]!=s[r]) { dp[l][r] = dp[l+1][r]+dp[l][r-1]-dp[l+1][r-1]; }else { dp[l][r] = dp[l+1][r]+dp[l][r-1]; dp[l][r] ++; } } } //printf("%d\n",dp[1] ); cout<<dp[1] <<endl; } return 0; }
相关文章推荐
- Again Palindromes - UVa 10617 dp
- uva10617 - Again Palindrome(dp)
- uva 10617(dp)
- UVa 10617 Again Palindrome(经典回文串区间DP)
- UVA - 10617 Again Palindrome 字符串的回文子串
- UVA 10617 区间DP
- UVA 10617 - Again Palindrome
- uva 10617
- UVa 10617 - Again Palindrome
- uva 10617 回文串个数
- UVA 10617
- UVA 10617 Again Palindrome
- UVA - 10617 Again Palindrome
- uva 10617 Again Palindrome (DP)
- Uva 10617 Again Palindrome(区间dp)
- UVa 10617 Again Palindrome(回文 区间dp)
- uva 10617 - Again Palindrome(dp)
- UVA 10617 Again Palindrome
- UVa 10617 Again Palindromes / 记忆化搜索
- UVA 10617 Again Palindrome