这道题目的意思就是排两排书,下面这排只能竖着放,上面这排可以平着放,使得宽度最小 根据题意可以得出一个结论,放上这排书的Width 肯定会遵照从小到大的顺序放上去的 Because the total thickness of vertical books is fixed it's good to calculate the minimum possible total width of horizontal books. 那么只需要模拟一遍放书的过程即可,不会TLE 不过正统解法是Dp Dp…
D. The Bakery Some time ago Slastyona the Sweetmaid decided to open her own bakery! She bought required ingredients and a wonder-oven which can bake several types of cakes, and opened the bakery. Soon the expenses started to overcome the income, so…
题意: 就是让构造一个直径为d的树 每个结点的度数不能超过k 解析: 先构造出一条直径为d的树枝 然后去遍历这条树枝上的每个点 为每个点在不超过度数和直径的条件下添加子嗣即可 #include <bits/stdc++.h> #define mem(a, b) memset(a, b, sizeof(a)) using namespace std; , INF = 0x7fffffff; int n, d, k; int cnt; struct node { int u, v; node(…