先写出朴素的DP方程f[i][j]=f[k][j-1]+h[k+1][i] {k<i}(h表示[k+1,j]有几个不同的数) 显然时间空间复杂度都无法承受 仔细想想可以发现对于一个点 i 从 k 转移了,证明了 1~k 中 k 一定是最优的,不论对于i或者i之后的任何点x都是如此,不存在对i最优但对i之后的任何点x更优,否则i也可以更优(因为只多了一段h[i+1][x](i<x),而这一段显然是相同的),其实打表也能看出来(orz CYC!) 证明: 假设a<b,k>l,a…
E. Hanoi Factory time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Of course you have heard the famous task about Hanoi Towers, but did you know that there is a special factory producing the…
Jam's problem again Time Limit: 5000/2500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 640 Accepted Submission(s): 210 Problem Description Jam like to solve the problem which on the 3D-axis,given N(1≤N≤100000)…