P1850 changing classrooms

meaning of the title:There are V classrooms. E has the right to have no edges (to ensure all classrooms are connected).    First there are n time periods, each time period, Niu Niu (volume.) Going to class $c_i$for class.    After class, he has to go to $c_{i+1}$for the next class.    At present, cattle can apply for m times, change the classroom, make the road less.    If I is applied to the time segment, the probability of $p_i$is changed to $d_i$with a probability of $c_i$(failure is equal to no change).    Of course, he can apply less or even apply.   ã...

Number of numbers in the sorted array

Title Description Statistics the number of digits in a sorted array. thinking The lowest method is still the count count. Of course, when you look at an ordered array, you should think of the dichotomy, find the duplicate numbers on the left and right, and then subtract the two. Answer Method 1 count class Solution: def GetNumberOfK(self, data, k): # write code here if not data or len(data) ==0: return 0 return data.count(k) Method 2, do not use count counting method. class Solution: def GetNumberOfK(self, data, k): # write code here ...

Concurrent marker scan (CMS) collector (to be completed)

The Concurrent Markup Scan (CMS) collector is designed for applications that require shorter garbage collection pauses and can share processor resources with the garbage collector while the application is running. For any application with low moratorium, this collector should be considered. Using the command line option to enable the CMS collector-XX:+UseConcMarkSweepGC。   Like other available collectors, CMS collectors are generational; therefore, both small and major collections occur CMSThe collector attempts to reduce pause time due to primary collection by tracking accessible objects ...

design_model(11)flyweight

1.Enjoy element model Pool technology is an important way to achieve, it can reduce the object created by the application, reduce the occupation of program memory, improve the performance of the program. 2.Example public class Color { private String color; public String getColor() { return color; } public void setColor(String color) { this.color = color; } } public class FlyWeight { private Map<String, Color> colors = new HashMap<>(); public Color getColor(String str) { if (colors.containsKey(str)) { return colors.get(str); } els...

Common command functions in startup.s files in STM32 development

Due to the popularity of C and the development of compilers, more and more software engineers seldom have access to assembly language in programming. In the development of ARM, we will inevitably encounter the compilation of startup file. In KEIL environment, startup. s file is generally used as startup code.Many engineers have a headache when they see this file. Here I will briefly introduce some common assembly instructions and pseudo-instructions. I hope it will be helpful to you. Next time I see the. s file, I will not find it so difficult to accept.   Remind you, in assembly code is not...

design_model(12)chain

1.Responsibility chain mode Avoid the coupling relationship between the sender and the receiver of the request. 2.Example public interface Leader { public abstract void leave(Apply apl); } public class Manager implements Leader { private Leader leader; public void leave(Apply apply) { if(apply.getI()>5) { System.out.println("The manager agrees.Leader.leave (apply);}else {System.out.println ("manager agrees");}}Public Leader getLeader () {Return leader;}Public void setLeader (Leader leader) {This.leader = leader;}}Public class Major implements Lea...

File related operations

#Non text files, using Rb, upload and download are binary, UTF-8, GBK form RB# f = open('f:\\123.txt', mode="rb",)# content = f.read()# f.write("you ae".encode("utf-8"))# print(content)# print(f)# f.close()#bypes ---------> str R# f = open("123", mode="r", encoding="utf-8")## content = f.read()## print(content,type(content))# print(f,type(f))# f.close()#W----> no file-->build have file-->first delete all content and then write# f = open("log", mode="w", encoding="utf-8")# f.write("can you understand")# f.close()# WB# f = open("log", mode="wb")# f.write("123".encode("utf-8"))# f....

Set operation correlation

#set -------> set# str# lis = [11,2,3,4]## for i in range(len(lis)):# print(i)## del lis[i]# print(lis)# # print(lis)# lis = [11,22,33,44]## for i in range(len(lis)):# lis.pop()## print(lis)# l1 = [11,22]# l2 = l1# l3 = l2# l3.append("a")# print(l1)# print(l2)# print(l3)dic = {"k1":"v1", "k2":"v2", "a3":"v3"}dic1 = {}# for i in dic:# if "k" not in i:# dic1.setdefault(i, dic[i])## dic = dic1# print(dic)## l = []## for i in dic:# if "k" in i:# l.append(i)# for i in l:# if i in dic:# del dic[i]## print(dic)#0 '' [] () {} set() ----> bo...