Computing power of addition algorithm
Addition is one of the four basic operations. It refers to the calculation of combining two or more numbers and quantities into one. The sign of addition is the plus sign "+". In addition, the items are connected by a plus sign
There are several important properties in addition. It is commutative, which means that the order is not important, and it is interrelated, which means that when more than two numbers are added, the order in which the addition is performed is not important. Repeated addition of 1 is the same as counting; Adding 0 does not change the result. Addition also follows related operations (such as subtraction and multiplication)addition is one of the simplest digital tasks. The most basic addition: 1 + 1, which can be calculated by five month old babies or even other animal species. In primary ecation, students are taught to carry out the superposition calculation of numbers in the decimal system, starting from one digit, and graally solving the more difficult number calculation
in general addition, the numbers are collectively referred to as addends, and the results are called sums; Addition is to transfer so many addends to the sum. This is distinguished from the factors to be multiplied
In fact, ring the Renaissance, many authors did not consider the first plus sign at all. Today, because of the exchange property of addition, "cannon" is rarely used, and these two terms are often referred to as addends The additive property of real number:add two numbers with the same sign, take the same sign as the addend, and add the absolute value
The sign of the addend with the largest absolute value is taken, and the smaller absolute value is subtracted from the larger absolute value Any number less than P > plus 0 still gets the original number The essence of addition:is exactly the same thing, that is, the repetition or accumulation of the same thing, which is the beginning of number operation. Different analogies, such as an Apple + an orange, can only be equal to two fruits, so there is a relationship between classification and classification. Subtraction is the inverse operation of addition; Multiplication is a special form of addition; Division is the inverse of multiplication; Power is a simple form of multiplication
The root ofis the inverse operation of power; Logarithm is to find the law in the terms of power; Derivative is developed from logarithm; Then there's differentiation and integration. The development of digital operation is a rule under more special circumstances and higher repetition
< H2 > References: network addition
the whole ten, the whole hundred, the whole thousand, so as to simplify the calculation
for example:
26 + 65 + 74 = (26 + 74) + 65 = 100 + 65 = 165< br />123+965+877=123+877+965=1000+965=1965< br />163+836+9=163+837-1+9=163+837+8=1000+8=1008
...
for reference.
matrix addition can only be added if the matrix is of the same type
for example,
two 3-row and 3-column matrices can only be added
3-row and 3-column matrices can not be added with 2-row and 3-column matrices
the calculation rule is to add the corresponding terms (A1, A2) +
(B1, B2) = (a1 + A2, B1 + B2)
matrix multiplication is mainly that the number of columns of the former term must be equal to the number of rows of the latter term
m * n
and
n * k
can be multiplied
while m * n
and m * n can't
calculation rules
the first element of the result is the first row of the first matrix multiplied by the first column of the second matrix
the first row of the second element multiplied by the second column, and so on
for example
(a) 1, A2) (B1, B2)
(A1 * B1 + A1 * B3, A1 * B2 + A2 * B4)
(A3,
A4)
times
(B3, B4)
equals
(A3 * B1 + A4 * B3, A3 * B2 + A4 * B4
)
at the beginning, you can almost cope with the school competition
then in the medium term
some water problems on OJ (can be used to practice and increase self-confidence)
(poj3299, poj2159, poj2739, poj1083, poj2262, poj1503, poj3006, poj2255, poj3094)
initial stage:
I. Basic Algorithm:
(1) enumeration. (poj1753, poj2965)
(2) greedy (poj1328, poj2109, poj21095), (poj2586)
(3) recursion and divide and conquer method.
(4) recursion.
(5) construction method. (poj3295)
(6) simulation method. (poj1068, poj2632, poj1573, poj2993, poj2996)
2. Graph algorithm:
(1) depth first traversal and breadth first traversal of graph.
(2) shortest path algorithm (Dijkstra, Bellman Ford, Floyd, heap + Dijkstra)
(poj1860, (3) minimum spanning tree algorithm (prim, Kruskal)
(poj1789, poj2485, poj1258, poj3026)
(4) topological ordering (poj1094)
(5) maximum matching of bipartite graph (Hungarian algorithm) (poj3041, poj3020)
(6) augmented path algorithm of maximum flow (km algorithm). (poj1459, poj1258, poj3026), 3. Data structure.
(1) string (poj1035, poj3080, poj1936)
(2) sort (fast row, reced side-by-side (related to reverse order number), heap (poj2388, poj2299)
(3) application of simple union search set.
(4) hash table, binary search and other efficient search methods (hash of number, hash of string)
(poj3349, poj3274, poj2151, poj1840, poj22002, (5) Huffman tree (poj3253)
(6) heap
(7) trie tree (static and dynamic tree building) (poj2513)
(4) simple search
(1) depth first search (poj2488, poj3083, poj3009, poj1321, poj2251)
(2) breadth first search (poj3278, poj1426, poj3126, poj3087. Poj3414)
(3) simple search skills and pruning (poj2531, poj1416, poj1416, poj2503)
(4) simple search skills and pruning, (poj26761129)
v. dynamic programming
(1) knapsack problem. (poj1837, poj1276)
(2) simple DP (refer to page 149 of Lrj):
1. E [J] = opt (poj3267, poj1836, poj1260, poj2533)
2. E [I, J] = opt (longest common subsequence)
(poj3176, poj1080, poj1159)
3. C [I, J] = w [I, j] (1) Combinatorics:
1. Principle of addition and principle of multiplication.
2. Permutation and combination.
3. Recursion.
(poj3252, poj1850, poj1019, poj3252, poj1850, poj1019, (poj1942)
(2) number theory.
1. Prime number and integer division problem.
2. Base digit.
3. Congruence mole operation.
(poj2635, poj3292, poj1845, poj2115)
(3) calculation method.
1. Related knowledge of solving monotone function by dichotomy. (poj3273, poj3258, poj1905, poj1905, (poj3122)
7. Computational geometry.
(1) geometric formula.
(2) application of cross proct and point proct (such as the judgment of line segment intersection, the distance from point to line segment, etc.) (poj2031, poj1039)
(3) simple algorithm of polygonal type (calculating area) and related judgment (whether points are in polygonal type, polygonal type intersects or not)
(poj1408, poj1584)
(4) convex hull. (poj2187, poj1584), (poj1113)
intermediate:
1. Basic algorithm:
(1) application of C + + standard template library. (poj3096, poj3007)
(2) training of more complex simulation problems (poj3393, poj1472, poj3371, poj1027, poj2706)
2. Graph algorithm:
(1) establishment and solution of difference constraint system. (poj1201, poj2983)
(2) minimum cost maximum flow (poj2516, poj2706), (poj2185)
(3) biconnected components (poj2942)
(4) strongly connected branches and their contraction points. (poj2186)
(5) cut edges and cut points of graphs (poj3352)
(6) minimum cut model and network flow protocol (poj3308,)
3. Data structure.
(1) line segment tree. (poj2528, poj2828, poj2777, poj2886, poj2750)
(2) static binary search tree. (poj2482, (poj2352)
(3) tree group (poj1195, poj3321)
(4) RMQ. (poj3264, poj3368)
(5) advanced application of parallel search. (poj17032492)
(6) KMP algorithm. (poj1961, poj2406)
(4) search
(1) optimal pruning and feasibility pruning
(2) skills and optimization of search (poj3411, poj1724)
(3) memory search (poj3373, poj3324)
, Dynamic programming (1) complex dynamic programming (such as dynamic programming solving special implementer quotient problem)
(poj1191, poj1054, poj3280, poj2029, poj2948, poj1925, poj3034)
(2) dynamic programming of recording state (poj3254, poj2411, poj1185)
(3) tree dynamic programming (poj2057, poj1947, poj2486, poj2486, poj1691), (1) combinatorial mathematics:
1. Inclusion exclusion principle.
2. Drawer principle.
3. Permutation group and Polya theorem (poj2286, poj2409, poj3270, poj1026).
4. Recurrence relation and generating function.
(2) mathematics.
1. Gauss elimination method (poj2947, poj1487, poj2065, poj1166, (poj1222)
2. Probability problem. (poj3071, poj3440)
3. GCD, extended Euclidean (Chinese remainder theorem) (poj3101)
(3) calculation method.
1.0/1 fractional programming. (poj2976)
2. Trisection method for solving single peak (Single Valley) extremum.
3. Matrix method (poj3150, poj3422, (poj3070)
4. Iterative approximation (poj3301)
(4) randomization algorithm (poj3318, poj2454)
(5) miscellaneous problems.
(poj1870, poj3296, poj3286, poj1095)
7. Computational geometry.
(1) discretization of coordinates.
(2) scan line algorithm (such as finding the area and perimeter of a rectangle, and, It is often used with line segment tree or heap.
(poj1765, poj1177, poj1151, poj3277, poj2280, poj3004)
(3) polygon kernel (half plane intersection) (poj3130, poj3335)
(4) comprehensive application of geometric tools. (poj1819, poj1066, poj2043, poj3227, poj2165, Poj3429
)
Advanced:
1. Basic algorithm requirements:
(1) fast code writing, concise but not losing style
(poj2525, poj1684, poj1421, poj1048, poj2050, poj3306)
(2) ensuring correctness and efficiency. Poj3434
2. Graph algorithm:
(1) degree limited minimum spanning tree and k-th shortest path. (poj1639)
(2) shortest path, The theory of minimum spanning tree, bipartite graph and maximum flow problem (mainly model building and solution)
(poj3155, poj2112, poj1966, poj3281, poj1087, poj2289, poj3216, poj2446
(3) optimal ratio spanning tree. (poj2728)
(4) minimum tree graph (poj3164)
(5) sub small spanning tree.
(6) undirected graph, graph, graph, graph, graph, graph, graph, graph, graph, graph, graph, graph, graph, graph, graph, graph, graph, graph, graph, graph, graph, graph, graph, graph, graph, graph, graph, graph, graph (1) the establishment and application of trie graph. (poj2778)
(2) LCA and RMQ problems (LCA) have offline algorithm (Union Search + DFS) and online algorithm
(RMQ + DFS)) (poj1330)
(3) two terminal queue and its application (maintenance of a monotonic queue), (poj2823)
(4) left leaning tree (merging heap).
(5) suffix tree (a very useful data structure, also a hot topic in the competition area).
(poj3415, poj3294)
IV. search
(1) more troublesome search topic training (poj1069, poj3322, poj1475, poj1924, poj3322, poj3322, poj3322, poj3415, poj3294), (poj2049, poj3426)
(2) state optimization of extensive search: use M-ary number to store state, convert to string hash table to judge weight, compress storage by bit
state, bidirectional extensive search, a * algorithm. (poj1768, poj1184, poj1872, poj1324, poj2046, poj1482)
(3) optimization of deep search: use bit operation as far as possible, prune as possible, rece function parameters as much as possible Dynamic programming (1) dynamic programming that needs data structure optimization.
(poj2754, poj3378, (poj3017)
(2) quadrilateral inequality theory.
(3) more difficult state DP (poj3133)
VI. mathematics
(1) combinatorics.
1. Mobius inversion (poj2888, poj2154)
2. Partial order relation theory.
(2) game theory.
1. Minimax process (poj3317, poj2154), [poj1085]
2. Nim problem.
7. Computational geometry.
(1) intersection of half plane (poj3384, poj2540)
(2) establishment of viewable (poj2966)
(3) minimum circle covering of point set.
(4) opposite heel point (poj2079)
8. Comprehensive problem.
(poj3109, poj1478, poj1462, poj2729, poj2048, poj3336, poj3315, poj2148, poj1263)
Integer addition rule:
integer addition is a kind of basic addition operation. Addition is to combine more than two integers into a number, and the result is called sum. The sign of addition is plus sign. In addition, the items are connected by a plus sign. Put sum after equal sign (=)
If the sum of 1, 2 and 4 is 7, it is written as 1 + 2 + 4 = 7integer subtraction rule:
integer subtraction rule can be expressed in three situations:
1, one digit or two digits minus one digit, and difference is the subtraction rule of one digit. According to the relationship that subtraction is the inverse operation of addition, it can be calculated by using the addition table
2. The same digit is aligned, starting from the digit subtraction, which digit is not enough for subtraction, borrow one from the previous digit as ten, and then subtract again
For any number a, there are always A-A = 0, A-0 = a, 0-0 = 0
extended data:
law
1, addition
additive commutative law: two numbers add, exchange the position of addends, and remain unchanged. a+b=b+a
Law of combination of addition: add three numbers, add the first two numbers first, or add the last two numbers first, and the sum remains unchanged a+b+c=a+b+c
Subtraction subtracting a number is equal to adding the opposite number of the number. a-b=a+-b Subtracting a number and adding a number is equal to subtracting the difference between the two numbers. a-b+c=a-b-c In continuous subtraction, first add up the two subtracted numbers, and then subtract the sum of the two subtracted numbers from the subtracted number, with the difference unchanged. a-b-c=a-b+c1, first 6 + 7 = 13, then 40 + 13 = 53
2, 46 + 7 = 46 + 4 + 3 = 50 + 3 = 53
as for the skills of operation, there are many, generally simple calculation of operation laws and properties, such as addition exchange law, addition combination law, continuous subtraction property, multiplication exchange law, multiplication combination rate, division quotient invariance property, etc.. Teachers will teach students to use these knowledge flexibly at different stages to improve their computing ability
the method of rounding up ten is just a kind of calculation skill.
2. Training for counting addends less than or equal to 5.
example: 9 + 5 or 5 + 9, use fingers to represent the smaller number, and memorize the larger number, And write it down as 10, that is to say, 5 is represented by fingers. Stretch out 5 fingers, because 9's friend is 1. Subtract one from the 5 fingers stretched out, and there are still 4 left. Add 10 and 4 in your heart, so 9 + 5 = 14; 9 + 4 or 4 + 9, 9 + 3 or 3 + 9; 9 + 2 or 2 + 9 can use this method. This method can be summarized as:
9 plus minus 1 from the outstretched finger, 8 plus minus 2 from the outstretched finger, 7 plus minus 3 from the outstretched finger... The remaining few fingers are more than ten.
three, two addends are more than 5 of calculation training.
1, if two addends are more than 5, choose the smaller one minus 5, for example, The smaller number is 6 minus 5 to leave 1, 7 minus 5 to leave 2, 8 minus 5 to leave 3, if they are all 9, use 9 minus 5 to leave 4. Use fingers to represent the remaining number, and remember 15 in mind.
2, for example, 9 + 6 or 6 + 9, the smaller number is 6, first subtract 5 from 6 to leave 1, then subtract 1 to get 0, and remember 15,15 plus 0 to get 15, that is, 9 + 6 or 6 + 9 to get 15.9 + 7 or 7 + 9, the smaller number is 7, and subtract 5 from 7 to get 2, Use your finger to represent 2, and remember 15 in your heart, because 9's friend is 1. Subtract 1 from 2 of your finger, and there is still 1, 1 plus 15 to get 16, that is, 9 + 7 = 16
9 + 8 or 8 + 9. First, subtract 5 from 8 to get 3, use your finger to represent 3, then subtract 1 to get 2, and add 15 and 2 in your heart to get 17, that is, 9 + 8 = 17. By analogy, you can complete the calculation of 8 + 7 or 7 + 8, 6 + 8 or 8 + 6, 7 + 6 or 6 + 7
{
float
a,b;< br />while(1)
scanf("% f%f",& a,&b);< br />printf("% f", a+b);< br />}