【动态规划】美妙的歌声 题目 解题思路 设f[i][0/1]为唱到第i位,结尾为0/1(da为0,do为1) 枚举上一段最后的位置,其答案*2的中间s个数次方的累加和为结果 代码 #include<iostream> #include<cstdio> #include<cmath> using namespace std; string s; int n,l,r,a[5010]; long long power[5010],f[5010][3],mo; int main() { freopen("listen.in","r",stdin)