首先我们可以写一个递归 #include<bits/stdc++.h> using namespace std; long long n; int main(){ long long f[1001]; memset(f,0,sizeof(f)); cin>>n; for(int i=1;i<=n;i++) { for(int j=1;j<=i/2;j++) { f[i]+=f[j]; } f[i]++; } cout<<f[n]<<endl; r…
一颗树,选取不相邻的点,求最大点权值 因为当前结点选或不选后后效性,所以我们加一唯来取消后效性 表示以i为根的树且i不选的最大价值 表示以i为根的树且i选的最大价值 显然有 #include<cstdio> #include<vector> #include<algorithm> #define REP(i, a, b) for(int i = (a); i < (b); i++) using namespace std; const int MAXN = 612…
题目描述 Bessie is planning the annual Great Cow Gathering for cows all across the country and, of course, she would like to choose the most convenient location for the gathering to take place. Each cow lives in one of N (1 <= N <= 100,000) different ba…