aみねちゃんの asura fieldTime limit:5000 mSec Memory limit:1024 KB problem Description
みねちゃん is a grade of excellent university sophomore, originally and like his sister general childhood sweetheart with a common college life, but one day was recognized in the school of the first beauty vindicate. Yet her true intention was to deceive the crowd and to みねちゃん her as a couple. みねちゃん, who has mastered one of his "secrets", is forced to pretend to be a "boyfriend". However, after this his "fiancee" also joined in, around the みねちゃん of the heroic Asura field to open this curtain! (Why is this script so familiar?) )
Another year of Valentine's Day, in order not to mistakenly into the hatchet end,みねちゃん must give three "girlfriend" to send three copies of the same gift (the difficulty of opening the harem is really big ah ~). As a local tyrants, みねちゃん nature is to buy a lot of things ready to give three girls, but when the goods sent home, みねちゃん one eye found something less! みねちゃん N orders at x East, each order containing exactly 3 gifts, (with the possibility of buying the same gift multiple times) results in only 3*n-1 pieces. Unfortunately, みねちゃん can only see a gift less one, do not know what is less, now have to entrust you according to the number of each item to check, in the end is what kind of less send a one (quantity is not a multiple of 3). You asked me why he didn't check himself? Please, someone else has three sister, how can have so many free time, so this boring thing still to you ~
Input
The first line an integer n, i.e. みねちゃん ordered n gifts altogether
The next number of 3*N-1 indicates the item number of the item sent. Because of the wide range of items in the X-east, the item number is a 10-bit decimal integer and may have leading zeros. There may be line breaks between numbers.
The input file is guaranteed to be no larger than 64M.
Output a number that represents the order number of the missing gift. Remember to change lines. Sample Input20000000001 0000000002 0000000002 0000000001 0000000002 Sample Output0000000001
- Ideas:
- Space restrictions are particularly small, so if using map<string,int> will be mle.
- This problem is actually to find out the number of occurrences will not be divisible by 3 of the order number. You can save the numbers on different bits of each order separately.
- So open an array of map[10][10]. Each order number is a 10-digit number, and one-dimensional I represents the I-bit. The two-dimensional J indicates that the number above the position I is J. A[I][J] indicates that, on the first position, the number J appears a[i][j] times.
- For example, in the case of the map[9][1]=2,map[9][2]=3. (Number of digits starting from 0)
C Alice and Bob and necklaceTime limit:1000 mSec Memory limit:32768 KB problem Description
Alice and Bob are playing games again today, they have a necklace, composed of n beads strung into a ring, now by Alice Initiator, two people in turn, each operation can be from an existing ring or chain, select a ring or a chain, and then select the above continuous 1~k beads removed, At this point the ring becomes a chain, and the chain becomes two new chains at most, and if all the beads of the ring or chain are eliminated, no new chains are formed. Who can not operate first even if lose, ask whether Alice or Bob will win.
Input
The first line is T (T <= 100), which indicates a T-group sample
The next T line is two digits n (1 <= n <=), and K (1 <= k <= 100) represents the number of beads and the maximum number of beads eliminated per wheel operation.
Output output T line, each line outputs Alice or Bob, indicating which party wins sample Input23 2 sample Outputalicebob
- Thinking:"game theory" when the game more than a few to guess ... But this is not the drop!
- Conclusion:
- If K==1,n is odd, the initiator wins
- N<=k, the initiator wins
- Other circumstances win
- Prove:
- K==1,n<=k, the results are obvious.
- N>k and K!=1, if n is an even number, whichever bead the initiator takes, the hand can take the beads that are symmetrical to his center. If n is an odd number, the hand can take the beads with his center symmetry, and take or take one more, so that the remaining beads achieve a similar symmetry in the case of the center.
- Expansion: Game theory
E⑨ Word cutTime limit:1000 mSec Memory limit:32768 KB problem Description
Reimu came back from hell and went to the temple, met the early seedlings, she found early seedlings learned a new spell card-secret method "⑨ word cut.
Early seedlings first to draw a n*m matrix, each lattice has a certain amount of psychic force (absolute value is not greater than 10, may be negative), each sub-matrix (that is, a matrix contained by the original matrix, at least one element) of the psychic value is the sum of the spirit value of the lattice contained within it. You need to find out the psychic value of the child matrix with the greatest psychic value. For example: N=3, m=4, The matrix is as follows:
-2 3 4-1
1-10 2 4
4 3 2 1
The maximum psychic force value is 12. The corresponding sub-matrices are
4-1
2 4
2 1
Input
The input contains multiple sets of data. (Data no more than 10 groups)
The first row of each set of data has two integers n,m (n,m<=100), which represents the length and width of the matrix.
The next n lines, m numbers per line, represent the psychic values in each lattice.
Output
Each set of data outputs a number that represents the maximum psychic value.
Sample INPUT1 7-9-9 8-1 1 7-43 4-2 3 4-11-10 2 3 2 1 Sample Output1512
- Idea: maximal continuous sub-sequence and, O (n). Turn this problem into the largest continuous subsequence of many (m* (m+1)/2) sequences. Complexity O (N3).
- maximum consecutive subsequence and : maxsum[i] = max{maxsum[i-1] + a[i], a[i]};
2016 Summer Singles first game 20160709