戳这里
1 /************************************************************** 2 Problem: 1962 3 User: rausen 4 Language: C++ 5 Result: Accepted 6 Time:0 ms 7 Memory:41824 kb 8 ****************************************************************/ 9 10 #include <cstdio> 11 #include <algorithm> 12 13 using namespace std; 14 const int N = 1e5 + 5; 15 const int K = 105; 16 17 int n, k; 18 int f[N][K]; 19 20 int main() { 21 int i, j; 22 scanf("%d%d", &n, &k); 23 for (i = 2; ; ++i) { 24 for (f[i][1] = i >> 1, j = 2; j <= k; ++j) 25 f[i][j] = max(f[i - 1][j] + f[i - 2][j - 2], f[i - 2][j] + f[i - 1][j - 1]) + 1; 26 if (f[i][k] >= n) { 27 printf("%d\n", i); 28 return 0; 29 } 30 } 31 return 0; 32 }
By Xs酱~ 转载请说明
博客地址:http://www.cnblogs.com/rausen