- 2020-11-24 00:10
*views 1*- Blue bridge
- data structure
- Python

<> test questions A: beautiful 2

【 Problem description 】

Xiao Lan likes it very much 2, This year is A.D 2020 year , He was very happy .

He was curious , In A.D 1 Year to A.D 2020 year （ contain ） in , How many digits of a year contain numbers 2?

This question is divided into two parts

ans = 0 for i in range(1,2021): if str(i).count("2") != 0: ans += 1 print(ans)

<> test questions B: Total number

【 Problem description 】

If a number is divided by 1 I have other divisors with myself , It is called a composite number . for example ：1, 2, 3 It's not a total ,4, 6 It's a sum .

From 1 reach 2020 How many total numbers are there .

The same question

ans = 0 for i in range(4,2021): for j in range(2,i//2+1): if i%j == 0: ans += 1

break print(ans)

<> test questions C: Factorial divisor

【 Problem description 】

Define factorial n! = 1 × 2 × 3 × · · · × n.

Excuse me? 100! （100 factorial ） How many divisors are there .

If you want to be violent , You can't get out .

<> test questions D: Essential ascending sequence

【 Problem description 】

Xiao Lan especially likes monotonous things .

In a string , If you take out several characters , It is monotonically incrementing to arrange these characters in the order in the string , Becomes a monotonically increasing subsequence of the string .

for example , In string lanqiao in , If you take out characters n and q, be nq Form a monotone increasing subsequence . Similar monotone increasing subsequences also exist lnq,i,ano wait .

Xiaolan found , Some subsequences have different positions , But the character sequence is the same , For example, the second character and the last character can be retrieved ao, You can also get the last two characters

ao. Xiao Lan doesn't think they are fundamentally different .

For a string , Xiao Lan wants to know , How many increasing subsequences are there in different nature ?

for example , For Strings lanqiao, The increasing subsequences with different nature are 21 individual . They are

l,a,n,q,i,o,ln,an,lq,aq,nq,ai,lo,ao,no,io,lnq,anq,lno,ano,aio.

For the following string （ common 200

A small English letter , Display in four lines ）：（ If you copy the following text to a text file , Be sure to check that the copied content is consistent with that in the document . There is a file under the examination directory

inc.txt, The content is the same as the text below ）

tocyjkdzcieoiodfpbgcncsrjbhmugdnojjddhllnofawllbhf

iadgdcdjstemphmnjihecoapdjjrprrqnhgccevdarufmliqij

gihhfgdcmxvicfauachlifhafpdccfseflcdgjncadfclvfmad

vrnaaahahndsikzssoywakgnfjjaihtniptwoulxbaeqkqhfwl

How many increasing subsequences are there in different nature ?

The estimation is done by dynamic programming , I didn't think of it in the exam .

<> test questions E: paper serpent

【 Problem description 】

Xiao Lan has a toy snake , All in all 16 section , It's marked with numbers 1 to 16. Each section is in the shape of a square . The two adjacent sections can be in a straight line or in a straight line 90 Degree angle .

Xiaolan has another one 4 × 4 The square box of , For storing toy snakes , The square of the box is marked with letters in turn A reach P common 16 Two letters .

Xiaolan can fold her toy snake into a box . He found that , There are many ways to put snakes in .

The figure below shows two options ：

Please calculate for Xiao Lan , How many different solutions are there . If there are two options , There is a segment of the toy snake in different boxes , It's a different plan .

Can not do .

<> test questions F: Tiangan dizhi

【 Problem description 】

In ancient China, tiangan dizhi was used to record the current year .

There are ten Heavenly stems , They are ： nail （jiǎ）, B （yǐ）, C （bǐng）, Ding （dīng）, E

（wù）, Oneself （jǐ）, Geng （gēng）, Symplectic （xīn）, Union （rén）, Kui （guǐ）.

There are twelve Earthly Branches , They are ： son （zǐ）, ugly （chǒu）, Yin （yín）, Mao （mǎo）, Chen （chén）, Already （sì）, Afternoon （wǔ）, not （wèi）, Shen （shēn）, Unitary （yǒu）, Xu （xū）, Hai （hài）.

Connect the heavenly stems with the earthly branches , It formed a year of heavenly stems and earthly branches , for example ： Jia Zi .2020 Year is the year of gengzi .

Every year , Both heavenly stems and earthly branches will move to the next . for example 2021 Year is the year of Xin Chou .

Every time 60 year , Heavenly stems will circulate 6 round , Dizhihui circulation 5 round , So tiangan dizhi chronicles every year 60 Once a year . for example 1900 year ,1960 year ,2020 Every year is the year of gengzi .

The year of a given year , Please output the year of tiangan dizhi .

【 Input format 】

The input line contains a positive integer , Indicates the year of A.D .

【 Output format 】

Output a Pinyin , Indicates the year of tiangan dizhi , Both tiangan and dizhi are expressed in lowercase Pinyin （ It doesn't mean tone ）, Do not add any extra characters between .

【 sample input 】

2020

【 sample output 】

gengzi

【 Scale and convention of evaluation case 】

For all evaluation cases , The year entered is no more than 9999 Positive integer of .

If you put the ad in this question 1 I'd like to do it in 2010 jiǎzǐ You can't do it anyway , It took me an hour and a half to solve this problem during the competition , I didn't know the starting point until later jiǎzǐ, Anti roll out is xinyou Just made it . It's killing people .

t = ["","xin","ren","gui","jia","yi","bing","ding","wu","ji","geng"] d = ["",

"you","xu","hai","zi","chou","yin","mao","chen","si","wu","wei","shen"] n = int(

input()) a,b = 1,1 for i in range(1,n+1): if a>10: a = a%10 if a%10 == 0: a = 10

if b>12: b = b%12 if b%12 == 0: b = 12 a += 1 b += 1 print(t[a-1]+d[b-1])

<> test questions G: Duplicate string

【 Problem description 】

If a string S Can be repeated exactly by a string K First time , We call it S yes K Repeat string . for example “abcabcabc” Can be seen as “abc” repeat 3

First time , therefore “abcabcabc” yes 3 Repeat string .

In the same way “aaaaaa” since 2 Repeat string , again 3 Repeat string and 6 Repeat string .

Now give a string S, Please calculate at least a few characters to modify , Can make S To become a K Substring ?

【 Input format 】

The first line of input contains an integer K.

The second line contains a string containing only lowercase letters S.

【 Output format 】

Output an integer to represent the answer . If S Cannot modify to K Repeat string , output 1.

【 sample input 】

2

aabbaa

【 sample output 】

2

【 Scale and convention of evaluation case 】

For all evaluation cases ,1 ≤ K ≤ 100000, 1 ≤ |S | ≤ 100000. among |S | express S Of

length .

This problem should not be difficult to write after careful analysis

def main(): k1 = int(input()) s = input().strip() n = len(s) k = n//k1 ans = 0

if k1 == 1: for i in s: if i != s[0]: ans += 1 print(ans) return r = [] if n%k

!= 0: print(-1) return for i in range(0,n,k): d = "" for j in range(i,i+k): d +=

s[j] r.append(d) maxV = 0 n1 = len(r) for i in range(n1): if maxV<r.count(r[i])

: maxV = r.count(r[i]) sm = "" for i in range(n1): if r.count(r[i]) == maxV: sm

= r[i] break for i in range(0,n,k): ind = 0 for j in range(i,i+k): if sm[ind] !=

s[j]: ans +=1 ind += 1 print(ans) main()

<> test questions H: answering question

【 Problem description 】

yes n Each student asked the teacher to answer questions at the same time . Each student estimated the time of answering questions in advance .

The teacher can arrange the order of answering questions , Students should enter the teacher's office in turn to answer questions .

The process of a student answering questions is as follows ：

* Enter the office first , No i What do you need si Millisecond time .

* Then students ask questions and teachers answer them , No i What do you need ai Millisecond time .

* After answering questions , My classmates are very happy , A message will be sent in the course group , The time needed can be ignored .

* Finally, the students packed up and left the office , need ei Millisecond time . General needs 10 second ,

20 Seconds or 30 second , Namely ei The value is 10000,20000 or 30000.

After a classmate left the office , Then the next student can enter the office .

Answer questions from 0 The moment begins . The teacher wants to arrange the order of answering questions reasonably , Make students in the course group

The sum of sending messages is the smallest

【 Input format 】

The first line of input contains an integer n, Represents the number of students .

next n that 's ok , Describe each student's time . Among them, No i The row contains three integers si, ai, ei, meaning

As mentioned above .

【 Output format 】

Output an integer , What is the minimum sum of messages sent by students in the course group .

【 sample input 】

3

10000 10000 10000

20000 50000 20000

30000 20000 30000

【 sample output 】

280000

【 Example description 】

according to 1, 3, 2 Answer questions in the same order , What are the message sending times 20000, 80000, 180000.

【 Scale and convention of evaluation case 】

about 30% Evaluation case of ,1 ≤ n ≤ 20.

about 60% Evaluation case of ,1 ≤ n ≤ 200.

For all evaluation cases ,1 ≤ n ≤ 1000,1 ≤ si ≤ 60000,1 ≤ ai ≤ 1000000, ei ∈ {10000, 20000,

30000}, Namely ei By all means 10000,20000,30000 one of .

This question looks a little scary , In fact, after understanding the questions, you will find that the minimum sum is the sum of the time from entering the office to leaving the office , And then the last one is not to add in the time to tidy up and leave the office ok It's over , That is, it can be solved with greed .

n = int(input().strip()) nums = [list(map(int,input().split())) for _ in range(

n)] r = [] for i in range(n): r.append([sum(nums[i]),nums[i][2]]) r.sort() ans =

0 s = 0 for i in range(n): ans += r[i][0]-r[i][1] + s s += r[i][0] print(ans)

<> test questions I: supply

【 Problem description 】

Xiao Lan is a helicopter pilot , He is in charge of the service to the mountain people n

A village transports goods . Every month , He goes to every village at least once , It can be more than once , Transport the materials needed by the village . Every village happens to have a heliport , The distance between every two villages is just a straight line .

Due to the limited size of the helicopter fuel tank , The distance of Xiaolan's single flight cannot exceed

D. Every heliport has a gas station , You can fill up the helicopter . Every month , Xiaolan starts from the headquarters , After delivering supplies to the villages, return to the headquarters . If it's convenient , Xiaolan can also refuel through the headquarters halfway .

Headquartered in 1 My village . Excuse me? , To complete a month's task , How long does Xiao Lan have to fly at least ?

【 Output format 】

Output one line , Contains a real number , Rounding reservation 2 Decimal place , Express the answer .

【 sample input 】

4 10

1 1

5 5

1 5

5 1

【 sample output 】

16.00

【 Example description 】

The four villages form a square shape .

【 sample input 】

4 6

1 1

4 5

8 5

11 1

【 sample output 】

28.00

【 Example description 】

The order of supply is 1 → 2 → 3 → 4 → 3 → 2 → 1.

【 Scale and convention of evaluation case 】

For all evaluation cases ,1 ≤ n ≤ 20, 1 ≤ xi, yi ≤ 104, 1 ≤ D ≤ 105.

Can not do .

<> test questions J: Blue jump

【 Problem description 】

Xiaolan made a robot , It's called blue jump , Because this robot basically walks

By jumping .

Blue jump can jump and walk , You can also turn around . The distance of each step of blue jump must be an integer , Each step can jump no more than k The length of . Because the balance of blue jump is not well designed , If you do it twice in a row

It's all jumping , And the distance between the two jumps is at least p, Blue jump will fall , This is what Xiaolan doesn't want to see .

Xiao Lan has received a special task , In a long time L

Blue jump on stage . Xiaolan wants to control the blue jump from the left side of the stage to the right , Then turn around , Then walk from the right to the left , Then turn around , Then walk from the left to the right , Then turn around , Go from the right to the left , Then turn around , So back and forth . In order to make the audience not too boring , Xiao Lan decided to let LAN Tiao Tiao walk in a different way each time . Xiao Lan records the distance of each step of the blue jump , Line up in order , Obviously, the number of this column is not more than one

k And he is L. This way, a row of numbers will come out . If the length of two columns is different , Or there is a different position value in the two columns , I think it's a different plan .

Will the blue jump jump in the premise of not falling , How many different schemes are there going from one side of the stage to the other .

【 Input format 】

The input line contains three integers k, p, L.

【 Output format 】

Output an integer , Express the answer . The answer could be big , Please output the answer divided by 20201114 The remainder of .

【 sample input 】

3 2 5

【 sample output 】

9

【 Example description 】

Blue jump has the following characteristics 9 A jump method ：

* 1+1+1+1+1

* 1+1+1+2

* 1+1+2+1

* 1+2+1+1

* 2+1+1+1

* 2+1+2

* 1+1+3

* 1+3+1

* 3+1+1

【 sample input 】

5 3 10

【 sample output 】

397

【 Scale and convention of evaluation case 】

about 30% Evaluation case of ,1 ≤ p ≤ k ≤ 50,1 ≤ L ≤ 1000.

about 60% Evaluation case of ,1 ≤ p ≤ k ≤ 50,1 ≤ L ≤ 109.

about 80% Evaluation case of ,1 ≤ p ≤ k ≤ 200,1 ≤ L ≤ 1018.

For all evaluation cases ,1 ≤ p ≤ k ≤ 1000,1 ≤ L ≤ 1018.

Technology

- Java407 articles
- Python218 articles
- Linux114 articles
- Vue106 articles
- MySQL91 articles
- SpringBoot70 articles
- javascript70 articles
- Spring63 articles
- more...

Daily Recommendation

©2019-2020 Toolsou All rights reserved,

Hikvision - Embedded software written test questions C Language application 0 The length of array in memory and structure is 0 In depth analysis data structure --- The preorder of binary tree , Middle order , Subsequent traversal How to do it ipad Transfer of medium and super large files to computer elementui Shuttle box el-transfer Display list content text too long 2019 The 10th Blue Bridge Cup C/C++ A Summary after the National Games （ Beijing Tourism summary ）unity Shooting games , Implementation of first person camera python of numpy Module detailed explanation and application case Study notes 【STM32】 Digital steering gear Horizontal and vertical linkage pan tilt Vue Used in Element Open for the first time el-dialog Solution for not getting element