"URAL 1223" Chernobyl ' Eagle on a Roof (legendary DP God optimized Eagle Egg)

Source: Internet
Author: User
Tags fread

"URAL 1223" Chernobyl ' Eagle on a Roof (legendary DP God optimized Eagle Egg)

Remember that the Jin Gian said this problem in many school races.

Today finally met the Buddha.

The worst is not the topic itself, but Chen Ben's five-weight optimization.

Now the realm only reaches the second level ...

The third, the monotony of the linear programming, and the subsequent diagram of the transfer complexity down to the LOG2 (n) part ....

I would like to say a little bit about the way I n2logn N^2logn. Stuck with the 1s past ... Good Konjac

That is, the initial DP sets an optimization, the optimization is good understanding, because the second test is the least number of times, then when the Eagle Egg number m allows two points to do, the output can be.

The rest of the bare-running DP.
DP[I][J] Represents the minimum number of times I have an eagle egg in a J-floor experiment.

Enumeration 1 <= m <= J,
Dp[i][j]=min1<=m<=j[max (Dp[i][m−1],dp[i−1][j−m]) +1] dp[i][j] = min_{1

I don't see the PPT. Even if there is a picture.

The idea is to throw the first Eagle egg on level m,
If it's broken, then it's the minimum number of experiments in the m-1 layer with i-1 eggs. +1 (dp[i-1][m-1]+1)
If it's not broken, it's using the I egg and then the minimum number of experiments in the M+1~J layer +1 (dp[i][j-m]+1)

And then it's gone ...

The code is as follows:

#include <iostream> #include <cmath> #include <vector> #include <cstdlib> #include <cstdio > #include <climits> #include <ctime> #include <cstring> #include <queue> #include <stack&
Gt  #include <list> #include <algorithm> #include <map> #include <set> #define LL Long Long #define Pr pair<int,int> #define FREAD (CH) freopen (CH, "R", stdin) #define FWRITE (CH) freopen (CH, "w", stdout) using namespace s
td
const int INF = 0X3F3F3F3F;
const int mod = 1E9+7;
Const double EPS = 1e-8;

const int MAXN = 1123;

int DP[10][MAXN];
    int main () {//fread ("");

    Fwrite ("");

    int n,m; 
            while (~SCANF ("%d%d", &m,&n) && (n+m)) {if (M >= ceil (log ((n+1) *1.0)/log (2.0)))
        printf ("%d\n", (int) ceil (log ((n+1) *1.0)/log (2.0)));

            else {memset (dp,0,sizeof (DP));

            for (int i = 1; I <= n; ++i) dp[1][i] = i; for (int i = 2; I <= M ++i) {for (int j = 1; j <= N; ++j) {Dp[i][j] = Dp[i][j
                    -1]+1; for (int k = 1; k < J; ++k) {Dp[i][j] = min (Dp[i][j],max (dp[i][k-1],dp[i-1) [J-k])
                    +1);
        }}} printf ("%d\n", Dp[m][n]);
}} return 0; }

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.