网站制作知识
[luoguP2875] [USACO07FEB]牛的词汇The Cow Lexicon(DP)
2025-01-03 14:13  点击:0

传送门

f[i] 表示前 i 个字符去掉多少个 的最优解

直接暴力DP

——代码

1 #include <cstdio> 2 #include <cstring> 3 #include <iostream> 4 5 int n, m, cnt, f[301]; 6 char s[301], a[601][26]; 7 8 inline int read() 9 16 17 inline int min(int x, int y) 18 21 22 int main() 23 42 if(k) f[i] = min(f[i], f[k 1] + cnt); 43 } 44 } 45 printf("%d\n", f[m]); 46 return 0; 47 }
View Code