随笔分类 - 动态规划
摘要:寻找串与其逆串的最长公共子序列。 因为此子序列必是回文串,剩下的字符就是需要插入的。 1 #include 2 #include 3 #include 4 #include 5 6 #define Max(a,b) a > b ? a : b 7 8 using namespace std; 9 10 char s1[5010],s2[5010];11 12 short int CountLen[5010][5010];13 14 int main()15 {16 int len;17 while(~scanf("%d",&len))18 {19 ...
阅读全文
摘要:Pick applesTime Limit: 1000ms Memory limit: 165536K有疑问?点这里^_^题目描述Once ago, there is a mystery yard which only produces three kinds of apples. The number of each kind is infinite. A girl carrying a big bag comes into the yard. She is so surprised because she has never seen so many apples before. Each
阅读全文
摘要:1 #include<cstdio> 2 #include<cstring> 3 4 int a[510][510]; 5 char m[510],z[510]; 6 7 int main() 8 { 9 int lm,lz,im,iz,i,t;10 while(gets(m+1) != NULL)11 {12 gets(z+1);13 lm = strlen(m+1);14 lz = strlen(z+1);15 lm++;16 lz++;17 if(lm > lz)...
阅读全文
摘要:#include<stdio.h>#include<string.h>int main(){ int i,j,js,s[1000],a[1000],b[1000]; while(~scanf("%d",&js)) { for(i = 0;i < js; i++) scanf("%d",&s[i]); a[0] = 1; int m = 0; for(i = 1;i < js; i++,m = 0) { for(j = 0;j < i; j++) ...
阅读全文
浙公网安备 33010602011771号