Bzoj 1962 Model Prince "guessing number problem"

Source: Internet
Author: User

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"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.