Brief Description:
Guessing number problem: There is an integer in the range of 1 to n that is guessed x, you can give an integer y each time. You will get the answer to your question after you ask the next question, that is, the size of x and Y. And if you get a K-x<y answer, the game is over, and you have to avoid this happening.
Analyse:
F[I][J], which represents the number of times I guess, the processing length of the condition of the J-X<y.
Friend Chain: The research paper of guessing number problem
CODE:
#include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include < algorithm> #include <vector> #include <string> #include <queue> #include <deque> #include <stack> #include <map> #include <set> #define INF 0x7fffffff#define SUP 0x80000000#define Mem (A, B) memset (A,b,sizeof (a)) using namespace Std;typedef long long ll;const int n=100007;int dp[n][111];int main () { int n,k; while (scanf ("%d%d", &n,&k) ==2) { int ans=0; for (int i=2;; i++) {for (int j=2;j<=k;j++) { Dp[i][j]=max (dp[i-2][j]+dp[i-1][j-1],dp[i-1][j]+dp[i-2][j-2]) +1; if (dp[i][j]>=n) { ans=i; break; } } if (ans) break; } printf ("%d\n", ans); } return 0;}
Bzoj 1962 Model Prince "guessing number problem"