1. It is known that a binary tree's pre-sequence traversal is ABCDEFGH, then its middle sequence traversal must not be:
A. CBEDAGFH
B. Badcfehg
C. DCEBFAHG
D. Cbdafehg
Answer: None
Test Center: two Fork Tree traversal
- Pre-sequence traversal: root around
- Middle sequence traversal: Zogen right
- Post-post traversal: Left and right root
2.10,000 people on the back of the number from 1 to 10000 in turn, they from small to large in turn, even out, a circle, from the remaining 5000 people again from the beginning of the number of small numbers, even out, until no one out. What is the number on the back of the last person to be out?
A. 1
B. 2049
C. 4097
D. 8193
Answer: D
Analysis: Pay attention to the question, is to ask the last time out of the person. A option is never a dequeue.
Train of thought: write out the serial number of each round, find out the rule, beg the last round the first number of
The first time out listed as 2,4,6,8 ...
The second time out listed as 3,7,11 ...
The third time out listed as 5,13,21 ...
then f (1) = 2;
F (2) =f (1) +pow (2,0) =3
F (3) =f (2) +pow (2,1) =f (1) +pow (2,0) +pow (2,1) =5
...
F (n) =f (n-1) +pow (2,n-2)
then f (n) =f (1) +pow (2,0) +pow (2,1) +...+pow (2,n-2) =k<10000, using the equal formula, simplifying the K=pow (2,n-1) +1<10000, Get Pow (2,n-1) =pow (2,13) =8192,k=8193
3. Read the code below to give the return value of handle (1024,256)
1 handle (A, b) { 2 if(a==0return b; 3 if (b==0return A; 4 i=a^b; 5 j= (a&b) <<1; 6 return handle (I,J); 7 }
Answer: 1280
Test Center: ^ xor (dissimilarity 1), & (same as 1 1), << left shift (A<<b,a b bit, a Times 2 b)
First round: a = 1024x768, B = up, I = 1280x720, j = 0
Second round: a = 1280,b = 0, execute statement
if (b==0) return A;
Output is 1280
4. The following is a pseudo-code of the number processing function, after reading, please give the return value of handle (12354)
1 handle (num) {2result =0; 3i =num;4 while(I! =0 ) 5 { 6i = i/Ten*Ten; 7result = result *Ten+ num-i; 8i = I/Ten; 9num = num/Ten; Ten } One returnresult; A}
Answer: 45321
Parse: Reverse output
5. A strange Letter:
Title Description:
Now you need to write a letter with a strange typewriter. Each line of the letter can hold a width of 100 characters, that is, if a character is written that results in a line width greater than 100, then another line will be written
The contents of the letter are made up of 26 lowercase letters in a-Z, and the width of each letter is agreed beforehand. For example, the character width convention is [1,2,3,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5], then the width of ' a ' to ' d ' four letters is 1,2,3,4, and ' e ' to ' Z ' width is 5
After writing the given content s into a letter according to the above rules, how many lines does this letter have? What is the last line width?
Input Example 1:
5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
HelloWorld
Output Example 1:
1 50
Example Illustration 1:
"5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5" specifies that each character width is 5
"HelloWorld" is the input string s
Since S is a total of 10 characters, it also occupies a total of 50 character widths, so it can be written on the same line
Input Example 2:
5 5 5 5 5 5 10 10 10 10 10 10 10 10 10 10 10 10 5 5 5 5 5 5 5 5
Hahahahahahahaha
Output Example 2:
2 20
Example Illustration 2:
"5 5 5 5 5 5 10 10 10 10 10 10 10 10 10 10 10 10 5 5 5 5 5 5 5 5" Specifies the width of each character
"Hahahahahahahaha" is the input string s
Since the h width is 10,a width of 5, the ' Hahahahahahah ' occupies 100 character widths that can be written on the first line, and the ' AHA ' is written on the second line, which is the last line. So the character width is 20.
1#include <cstdio>2#include <cstring>3#include <iostream>4#include <algorithm>5 using namespacestd;6 7 intMain ()8 {9 stringstr;Ten intnum[ -]; One for(intI=0; i< -; i++) A { -CIN >>Num[i]; - } theCIN >>str; - intCount=1, Len =0; - for(intI=0; I<str.length (); i++) - { + intn = num[str[i]-'a']; - if(len + n > -) + { ALen =N; atcount++; - } - Else - { -Len + =N; - } in } -cout << Count <<" "<< Len <<Endl; to return 0; +}
6. Confectionery Puzzles:
Xiao Ming is a teacher in a kindergarten. One day kindergarten director to the children each hair a candy, children get to find some students get candy color and their own, some classmates candy color and their own different.
Suppose each child only knows how many classmates and himself have got the same color candy.
After class, a part of the children excited to tell Xiao Ming teacher, and let Xiao Ming teacher guess, at least how many classmates got the candy.
For example, three children told Xiao Ming's teacher The result is as follows:
One of the first children found 1 people and their own candy color, the second child also found that 1 people and their own candy color, the third child found that there are 3 people and their own candy color.
The 12th child can think of each other with their own color, such as red;
The third child can no longer be red (otherwise the 12th child will find that there are 2 people and their own candy color), assuming he got the blue candy, then at least another 3 students to get the blue candy, eventually at least 6 children to get candy.
Now please help Xiao Ming to solve the puzzle.
1#include <map>2#include <vector>3#include <cstdio>4#include <cstring>5#include <iostream>6#include <algorithm>7 using namespacestd;8map<int,int>Map;9vector<int>A;Ten intMain () One { A inttot; - while(Cin >>tot) - { the a.push_back (tot); -map[tot]++; - } - intnum =0; + for(intI=0; I<a.size (); i++) - { + intx =A[i]; A if(Map[x] <=0) at { - Continue; - } - while(Map[x] >0) - { -num + = x +1; inMAP[X]-= x +1; - } to } +cout << Num <<Endl;; -}
NetEase Games (Mutual Entertainment)-game Test development Engineer-c++