
dp
巴扎嘿呀
学习知识图谱中~欢迎交流
展开
-
整数划分(计数dp)
//f[i][j],和为i,j个数字 #include<bits/stdc++.h> using namespace std; const int N=1100,mod=1e9+7; int f[N][N]; int main(){ int n;scanf("%d",&n); f[0][0]=1; for(int i=1;i<=n;i++){ for(int j=1;j<=i;j++){ f[i][j]=(f[i-1][j-1]+f[i-j][j])%mo.原创 2021-04-30 11:25:37 · 145 阅读 · 0 评论 -
愤怒的小鸟(状态压缩dp)
#include<bits/stdc++.h> using namespace std; const int N=18,M=1<<18; const double eps=1e-8; int n,m; int path[N][N]; int f[M]; struct node{ double x,y; }q[N]; int cmp(double x,double y){ if(fabs(x-y)<eps) return 0; if(x<y) return -1; .原创 2021-03-23 21:16:28 · 162 阅读 · 0 评论 -
G - Association for the Country of Mububa (dp)
#include<bits/stdc++.h> #define ll long long using namespace std; const int N=3e3+100; ll a[N]; ll dp[N]; ll sum[N]; int num[N]; int main(){ int n;scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%lld",&a[i]); sum[i]=sum[i-1]+a[i]; } .原创 2020-10-04 00:19:16 · 179 阅读 · 0 评论