摘要:
合并果子倒过来,贪心策略的正确性嘛。。大约凭借直觉想一下,因为次数要不停的往后累加,所以越小的越早合并越好,这样对后面影响小。严格证明就是huffman tree了。话说类似的贪心策略好像还有srm536的1000pt,因为那个题要求最大的合并方法,所以越小的越靠前合并对后面的影响就越小。这种题,先用stl爽一下!# include # include # include # include # include # include typedef long long ll;using namespace std;priority_queue,greater > q;int main(){ 阅读全文
摘要:
好暴力的dp啊。。有木有更简单的方法呢?# include # include # include # include # include # define MOD 1234567891using namespace std;typedef long long ll;ll dp[50][10][4][4][4][4];class TheBrickTowerHardDivTwo{public: int find(int C, int K, int H) { ll n,k,a,b,c,d,x,y,z,i,ans=0ll; for (a=0;a<C;++a) ... 阅读全文