Use dp[i][j] to indicate the first I task, a complete need J time, B completed need dp[i][j] time.The recursive equation is also easy to get outDp[i][j]=min (Dp[i-1][j]+b[i],dp[i-1][j-a[i])//Where A[i],b[i] respectively indicates the time required for A/b to complete the task I.Attached code1#include 2#include 3#include 4#include 5#include 6#include 7 using namespacestd;8Ifstream Fin ("divide.in");9Ofstream Fout ("Divide.out");Ten intdp[203][40005]={0},rws=0, rw[203][2]={0}; One intMainvoid) A {
QuestionGiven a 2D binary matrix filled with 0 's and 1 ' s, find the largest square containing all 1 's and return its area.For example, given the following matrix:1 1 1 1 11 0 0 1 0Return 4.Solution2-d Array. The changing condition is:T[i][j] = min (t[i][j-1], t[i-1][j], t[i-1][j-1]) + 1.1 Public classSolution {2 Public intMaximalsquare (Char[] matrix) {3 if(Matrix = =NULL|| Matrix.length )4 return0;5 introw = matrix.length, column = matrix[0].length, max = 0;
to come to the point of meeting and continue to the right, the lower left corner of the person can move up to meet the point of continued upstream or The upper-left corner of the person moves down to the meeting point and continues to move down, the lower left corner of the person to the right to meet the point to continue to move to the right as the maximum value simple DP1#include 2 using namespacestd;3 Const intMAXN =1005;4 intdp[4][maxn][maxn],a[maxn][maxn],n,m;5 intMain () {6 while(~S
the tree with this node as the root node is less than or equal to n/2. The node is a node that can be deleted;1#include 2#include 3#include 4#include 5#include 6#include 7 using namespacestd;8 Const intmaxn=10007;9 intDP[MAXN];Ten BOOLINPUT[MAXN]; Onevectorint>G[MAXN]; A intN; - voidInit () - { theMemset (DP,0,sizeof(DP)); -memset (Input,0,sizeof(input)); - for(intI=0; i) - g[i].clear (); + } - voidBFsintPointintfather) + { Adp[point]=1; at
these two subsequent states is the number of scenarios for the previous state.Of course, the next is to give the two-dimensional DP to the initial value, obviously dp[1][0]=1, and then found in fact dp[1][i]=i+1 (can be understood: when the jar is only a half-shaped pill and 1 tablets of complete pills, for the number of solutions, in fact, the main thing is to see the whole pill in the first few days to eat, For a total of i+1 days, it is clear that the number of C (i+1) (1) programs. Then I i
Given a 2D binary matrix filled with 0 's and 1 ' s, find the largest square containing all 1 's and return its area.For example, given the following matrix:1 1 1 1 11 0 0 1 0In the given two-dimensional character array, find out the number of 1 that the rectangle with the maximum total of 1 contains:Note that this is the equivalent of the area, only ask for the side length is very good to run. Side length with DP very good, this problem in fact with the former Youdao DP problem very much like,
DescriptionFarmer John commanded his cows to search forDifferent sets of numbers that sum to a given number. The cows use is numbers that is an integer power of2. Here is the possible sets of numbers that sum to7: 1)1+1+1+1+1+1+1 2)1+1+1+1+1+2 3)1+1+1+2+2 4)1+1+1+4 5)1+2+2+2 6)1+2+4Help FJ count all possible representations forA given integer N (11, the, the).InputA single line with a single integer, N.Output as This 9 digits (inbase representation).Sample Input7Sample Output6SourceUsaco 2005 J
of "49" in the 1~n closed intervalExercisesDp[i][2] Length I contains the number of "49"Dp[i][1] length I does not contain "49" but the number of "9" highDp[i][0] The length of I does not contain the number of "49"Array A[i] stores every digit of n from low to high.DP[I][2]=DP[I-1][2]*10+DP[I-1][1]; Consider the "4" i-1 bit "9" for the I-bitDP[I][1]=DP[I-1][0];DP[I][0]=DP[I-1][0]*10-DP[I-1][1];Why do you want to increase your self by 1 before n processingBecause the problem is that the closed i
using namespacestd;6typedefLong Longll;7 Const intmaxn= One;8ll dp[2][1MAXN];9 Ten voidSolveintMintN) One { A if(mN) swap (m,n); - intCur=0; -Memset (DP,0,sizeof(DP)); thedp[cur][(11]=1; - for(intI=1; i) - for(intj=1; j) - { +cur^=1; - /*cur to be placed behind the second cycle, written in the triple loop.*/ +memset (Dp[cur],0,sizeof(Dp[cur])); A /*don't forget to clear the current state*/ at for(intk=0; K11; k++) -
Robot. Compared with the Open-loop control system, the walking path can be shortened effectively, the walking speed is increased By 5.66% and The walking time was shortened by 7.25%, whichverifies the feasibility and practicability of the Closed-loop control system.Key words:hexapod Robot Autonomous Navigation fuzzy neural network closed-loop control environmental perception2. Deep learning for control:the state of the ART and prospects Abstract: Deep learning have shown great potential and ad
Given a non-empty array containing only positive integers, find if the array can is partitioned into Subsets such the sum of elements in both subsets is equal.Note:
Each of the array element would not be exceed 100.
The array size would not be exceed 200.
Example 1:Input: [1, 5, one, 5]output:trueexplanation:the array can be partitioned as [1, 5, 5] and [11].Example 2:Input: [1, 2, 3, 5]output:falseexplanation:the array cannot is partitioned into equal sum subsets.Use DP to sol
time limit: 3 sspace limit: 128000 KBtitle level: Golden GoldTitle DescriptionDescriptionGiven n (n≤500,000) and n integers (more ordered), the output is sorted.Enter a descriptionInput DescriptionN and N integersOutput descriptionOutput Descriptionn Integers (Ascending)Sample inputSample Input512 11 10) 8 9Sample outputSample Output8 9 10) 11 12Data range and TipsData Size HintFor 33% of data n≤10000For another 33% of the data n≤100,000 0≤ per number ≤1000For 100% of data n≤500,000 0≤ per numb
The newly purchased module, the default is slave mode, baud rate 57600, 8 bit data bit, no test bit, 1 bit stop bit.Send +++a, enter command mode.1. Set the module nameAt+name=bt_shining2, set the transmitting power (maximum power +3dbm)At+tpl=83. Set the passwordat+pass=1234564, set the serial port parameters (baud rate 115200, 8 bit data bits, no test bit, 1 bit stop bit)at+uart=115200,8,0,05, set the boot welcome (superfluous, set to empty)at+hello=There are two modes of usr-ble101 master-sla
] represents the maximum length of the ascending sequence of the sequence with the first element of the beginning, and then the sequence DP should be doneTransfer from back to forward State dp[i] = max (Dp[i], dp[j] + 1) num[i] 1#include 2 3 #defineINF 10000000004 intnum[10005];//Data5 intdp[10005];//record to this maximum ascent length6 intans[10005];//Storing the answer7 intn,m;8 9 voidInit ()Ten { Onescanf"%d",n); A inti,j; - for(i=1; i) -scanf"%d",num[i]); the for(i=n;i>=1; i
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.