Control inversion (IOC) and dependency injection (DI) 22:57:47 Tags: dependency injection workplace leisure control reversing original works, allowing reprinting, please be sure to mark the reprinting in hyperlink form
Article Original source, author information, and this statement. Otherwise, legal liability will be held. Http://zhangjunhd.blog.51cto.com/113473/126530
1.
Control reversal
(Inversion o
I'm bored with it ..
In fact, the key to this question is not the method of reverse order, because it is also possible to use brute force.
To give a sequence with the length of n (n
I use array a [0 ~ N-1] to store raw data. You only need to find the sum of the reverse order of the original sequence, and then for each order of a [I] (0
1. Violence Law.
265 Ms
212 K
600 B
Problem: 1394 (minimum inversion number) Judge Status: A
This "Zen of design patterns" was not easy to get. At that time, I had the honor to ask Qin Xiaobo in the csdn forum. Reading such a classic book cannot be like reading a novel. It is intended to be a pleasure to go around for a long time. It is more about reading and changing questions. Why should we ask every key point. Teacher Qin Xiaobo's language is sometimes humorous and sometimes important. Mr. Qin Xiaobo explained the question of "Inverted" from the perspective of human thinking. In his
Minimum inversion number
Time Limit: 2000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/Others)Total submission (s): 7503 accepted submission (s): 4610Problem descriptionthe inversion number of a given number sequence A1, A2,..., an is the number of pairs (AI, AJ) that satisfy I
For a given sequence of numbers A1, A2 ,..., an, if we move the first m> = 0 numbers to the end of the seqence, we will
(which is difficult to prove and omitted), that is, if m and n are mutually qualitative, there are PHI (m) PHI (n) = PHI (Mn)
So for any
Or write it as follows:
The relationship between the Mobius function and the Euler function:
This is not too difficult to prove. I will understand it after I calculate it on paper.
Iii. Mobius Inversion
If two functions are defined in the positive integer set, F (N) and g (n) satisfy the f
PHP Chinese string Inversion instance codeThe PHP string inversion function, String Strrev (String $str), has only one parameter, which is the string to invert. Instance Program:Echostrrev ("Hello world!"); Outputs "!dlrowolleh" UTF8 Chinese string Inversion instance code:function Strrev_utf8 ($STR) {return join ("", Array_reverse (Preg_split ("//u", $str)));}Pri
Spring's inversion of control (IOC) and Dependency Injection (DI) detailedThe following (IOC) control inversion is introduced first:The so-called control inversion is that the application itself is not responsible for the creation and maintenance of dependent objects, and the creation and maintenance of dependent objects is the responsibility of the external cont
most commonly used. Automatic injection of dependent objects is achieved by tagging @Inject annotations before the declaration of the field.Human { ... Human () {}} The above code looks amazing: Just add an annotation and the Father object will be automatically injected? How is this injection process done?Essentially, if you just write a @Inject note, Father is not automatically injected. You also need to use a dependency injection framework and make a simple configuration. Now the Java l
Defined:high-level modules should not rely on low-level modules, both of which should rely on their abstraction; abstractions should not rely on detail; detail should rely on abstraction.The problem: Class A is directly dependent on class B, and if you want to change class A to dependent Class C, you must do so by modifying the code for Class A. In this scenario, Class A is typically a high-level module, responsible for complex business logic, Class B and Class C are low-level modules responsibl
1. Reliance on
Dependence is a connection, where it is used to rely on it, and a system cannot completely avoid dependence. If one of your classes or modules does not use it in the project, congratulations, you can remove it from the project or exclude it, because there is no place to rely on it. Let's look at a simple example:
It is a simple example of a user playing a file with a player, and the user action is a PlayMedia method in the Operationmain class, opening a player and selecting a
Minimum inversion number
Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)Total submission (s): 4904 Accepted Submission (s): 2991
Problem Description the inversion number of a given number sequence A1, A2, ..., the number of pairs (AI, AJ) that s Atisfy i
For a given sequence of numbers a1, A2, ..., an, if we move the first m >= 0 numbers to the end of the seqence, we'll
Minimum inversion number Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)Total submission (s): 19452 Accepted Submission (s): 11701 Problem Description the inversion number of a given number sequence A1, A2, ..., the number of pairs (AI, AJ) that s Atisfy i For a given sequence of numbers a1, A2, ..., an, if we move the first m >= 0 numbers to the end of the seqence, we'll Ob
Minimum Inversion numberTime limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)Total Submission (s): 13942 Accepted Submission (s): 8514problem DescriptionThe inversion number of a given number sequence A1, A2, ..., is the number of pairs (AI, AJ) that satisfy I For a given sequence of numbers a1, A2, ..., an, if we move the first m >= 0 numbers to the end of the seqence, we'll Obtain
Link: HuangJing
This topic can be used by both the brute force and line segment trees, but a rule must be mastered ..
When the first element moves to the end of the team, you can reduce a [I] Reverse Order pairs, and then add n-1-a [I] Reverse Order pairs.
As you can see, if 1 is moved to the end of the team, the reverse order of 1> 0 is reduced, and the reverse order of 2> 1, 3> 1, 4> 1 is increased ..
So we can find this rule well ..
The brute-force method is to simulate it directly ..
The li
Minimum inversion number
Time Limit: 2000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/Others)Total submission (s): 10326 accepted submission (s): 6359
Problem descriptionthe inversion number of a given number sequence A1, A2,..., an is the number of pairs (AI, AJ) that satisfy I
For a given sequence of numbers A1, A2 ,..., an, if we move the first m> = 0 numbers to the end of the seqence, we w
The dependence inversion principle is dependent on abstraction, not specific. Simply put, we need to program the abstraction rather than the implementation, which reduces the coupling between the customer and the implementation module, the concepts such as IOC, Di, and IOC container are extended.
For process-oriented development, the upper layer calls the lower layer, and the upper layer depends on the lower layer. When the lower layer changes dram
C-minimum Inversion numberTime limit:1000MS Memory Limit:32768KB 64bit IO Format:%i64d %i64 U DescriptionThe inversion number of a given number sequence A1, A2, ..., is the number of pairs (AI, AJ) that satisfy I For a given sequence of numbers a1, A2, ..., an, if we move the first m >= 0 numbers to the end of the seqence, we'll Obtain another sequence. There is totally n such sequences as the following:
http://acm.hdu.edu.cn/showproblem.php?pid=1394Minimum Inversion numberproblem DescriptionThe inversion number of a given number sequence A1, A2, ..., is the number of pairs (AI, AJ) that satisfy I For a given sequence of numbers a1, A2, ..., an, if we move the first m >= 0 numbers to the end of the seqence, we Would obtain another sequence. There is totally n such sequences as the following:A1, A2, ..., An-
Minimum Inversion numberTime limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)Total submission (s): 14879 Accepted Submission (s): 9082Problem DescriptionThe Inversion number of a given number sequence A1, A2, ..., the number of pairs (AI, aj) that SA Tisfy i For a given sequence of numbers a1, A2, ..., an, if we move the first m >= 0 numbers to the end of the seqence, we'll Obtain
Minimum Inversion numberTime limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)Total Submission (s): 13797 Accepted Submission (s): 8423 Problem DescriptionThe Inversion number of a given number sequence A1, A2, ..., the number of pairs (AI, aj) that SA Tisfy i For a given sequence of numbers a1, A2, ..., an, if we move the first m >= 0 numbers to the end of the seqence, we'll Obtain
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.