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;}