SRM 451 div1 (Practice)

Source: Internet
Author: User

250pt:

        1234+      12340+     123400+    1234000+   12340000+  123400000+ 1234000000------------  1371110974

The magic source of a number is the smallest positive integer x, satisfying sigma (x * 10 ^ I) [I = 0 ~ N] = this number.

As mentioned above, 1234 is called the magic source of 1371110974, which is actually X * (1111111) = this number. The minimum X is the maximum 1111... 111.

500pt:

For 50 points in the grid, the grid size is 10000. You can go through a few points at most from (0, 0). The condition is: each time the y direction can only offset one unit, and the X direction can offset K, but it must be strictly greater than the last offset KP, that is, the span on the X direction is getting bigger and bigger, and the span on the Y direction remains unchanged.

I can think about the problem of being killed by heroes for half a day ....

In fact, the key is that the coordinates of X are not easy to handle, but you only need to note the two features to easily AC this question.

1: this person's route is based on these points and has nothing to do with other coordinate points.

2: at the same point, the shorter the step size, the larger the selection space for the future. Compared to the State S in the same state but the step size is longer than others, the point S can reach, this State can certainly be reached, but the person in the s State may not be able to go to the point that can be reached at a short step, so the state will come out...

int dp[55][55] ;struct node {    int x,y;    bool operator < (const node& cmp) const {        return y < cmp.y ;    }}in[55];void Min(int &x,int y){    if(x == -1 || y < x) x = y;}int BaronsAndCoins::getMaximum(vector<int> x, vector<int> y){    memset(dp,-1,sizeof(dp));    dp[0][0] = 0;    int n = x.size();    in[0].x = 0; in[0].y = 0;    for(int i = 1; i <= n; i++)    {        in[i].x = x[i-1];        in[i].y = y[i-1];    }    sort(in+1,in+n+1);    for(int i = 0; i < n; i++)    {        for(int j = 0; j < n; j++) if(dp[i][j] != -1)        {            for(int k = i+1; k <= n; k++) if(in[k].x > in[i].x &&in[k].y > in[i].y)            {                int step = dp[i][j];                int delta_col =  in[k].y - in[i].y;                int delta_row =  in[k].x - in[i].x;                int val = (step+1+step+delta_col)*delta_col/2;                if(val > delta_row) continue;                int extra = (delta_row - val) / delta_col;                if((delta_row-val) % delta_col != 0)extra ++;                Min(dp[k][j+1],step+delta_col+extra);            }        }    }    int ans = 0;    for(int i = 0; i <= n; i++)    {        for(int j = 0; j <= n; j++)        {            if(dp[i][j] != -1) ans = max(ans,j);        }    }    return ans;}

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.