摘要: 这个题是数位dp,dp[i][j][h]表示到第i为有h个0,j=1小于0等于,可以求出答案。 #include<stdio.h> int dp[41][2][41];//kge1 int a[41],lena; void init(){ dp[1][1][1]=dp[1][0][0]=1; for 阅读全文
posted @ 2020-08-30 22:06 __int128 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 题目链接:https://www.luogu.com.cn/problem/P3195 对于这道题,可以用斜率优化的方法, 转移方程 dp[i]=min(dp[j]+(i-j-L-1+sun[i]-sum[j])^2),i>j; 可以转化为 (2(sun[i]+i)(sum[j]+j+L)+(dp[ 阅读全文
posted @ 2020-08-30 21:49 __int128 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 这个题可以用莫队的方法来解决,通过创建数组来保存数的出现个数,再在每次添加或删除的时候保存一个答案,这样就能做出这道题。 #include<stdio.h> #include<math.h> struct node{ int l,r,id; }a[100001],pxr[100001]; int n 阅读全文
posted @ 2020-08-30 21:47 __int128 阅读(141) 评论(0) 推荐(0) 编辑