As we all know, the Fibonacci series are often involved in computers. In this paper, we use linear algebra to obtain the general formula of the generalized Fibonacci series.
In the broad sense, the definition of the Fibonacci series (custom, may not be rigorous enough, please advise) is as follows:
And a and B meet a ^ 2 + 4b> 0 (the reason is that the denominator is greater than 0)
The recurrence formula shows that:
(1)
OK! There a
instructions, so we do not consider this column matrix multiplicationWe find that f[i-1] by this matrix becomes the f[i] how is this matrix to be asked? KMP algorithm, for each length of the prefix enumeration next character to transfer the specific wording see the codeF Initial value is f[0][0]=1,f[0][x]=0 (x>0)So
Wrote a morning ... Because the length of the M is also counted in the ...DP (i, j) indicates that the ticket number before I character matches the number of scenarios for the first J of the unlucky number. KMP preprocessing, and then for J enumeration, the number 0~9 is also enumerated to calculate that f (i, j) represents DP (X-1, J) Contribution to DP (x, i). Then use the matrix to quickly power. Time complexity O (M3Logn + m) ---------------------
Test Instructions:Link slightlyMethod:AC automata + matrix multiplicationparsing:and POJ 27,781-like questions. The general idea is that when we build an AC automaton, we need to be aware that if a point is the end of a string, then the nodes below are considered the end nodes. Then it is good to assign the internal values of the matrix according to the AC automata. The assigned
1009: [HNOI2008]GT ExamTime Limit: 1 Sec Memory Limit: 162 MBSubmit: 2230 Solved: 1364DescriptionAshen ready to enroll in the GT exam, the ticket number is n-digit x1x2....xn (0InputThe first line enters N,m,k. The next line is to enter the number of M bits. 100% data nOutputAshen want to know how many kinds of numbers do not appear unlucky numbers, the result of output modulus K redundancy.Sample Input4
Description
Ashen ready to enroll in the GT exam, the ticket number is n-digit x1x2....xn (0Input
The first line enters N,m,k. The next line is to enter the number of M bits. 100% data nOutput
Ashen want to know how many kinds of numbers do not appear unlucky numbers, the result of output modulus K redundancy. Sample Input
4 3
111
Sample Output
81
HINT
Source
Set DP[I][J] The number of schemes that match the first number of numbers to the fi
1009: [HNOI2008]GT exam
Time limit:1 Sec Memory limit:162 MB
submit:2230 solved:1364
Description
Ashen ready to enroll in the GT exam, the ticket number is n-digit x1x2....xn (0
Input
The first line enters N,m,k. The next line is to enter the number of M bits. 100% data n
Output
Ashen want to know how many kinds of numbers do not appear unlucky numbers, the result of output modulus K redundancy.
Sample
1009: [HNOI2008]GT exam Time
limit:1 Sec Memory limit:162 MBsubmit:2745 solved:1694[Submit] [Status] [Discuss]
DescriptionAshen ready to enroll in the GT exam, the ticket number is n-digit x1x2 .... Xn (0His unlucky math a1a2 ... AM (00InputThe first line enters N,m,k. The next line is to enter the number of M bits. nOutputAshen want to know how many kinds of numbers do not appear unlucky numbers,
Portal: http://www.lydsy.com/JudgeOnline/problem.php?id=1009A good question, so that f (i, j) to indicate that the test number matches to I bit, the post J bit is an unlucky string of the first J-bit, then for each state, is a linear combination of the previous state, so you can use the matrix to accelerate.#include _bzoj1009 [HNOI2008]GT Exam "Matrix accelerat
Original question description: A Shen is going to sign up for the GT test. the admission ticket number is n digits x1x2... Xn (0 Analysis: Sputation: I almost fell victim to the details of this question. At first, I thought about DP, but the status transfer was disgusting. Let's change the way we use KMP to construct an automatic machine of. Then this question is converted into the number of paths that run and run on the automatic machine
"BZOJ1009" [HNOI2008]GT Exam descriptionAshen ready to enroll in the GT exam, the ticket number is n-digit x1x2 .... Xn (0His unlucky math a1a2 ... AM (00InputThe first line enters N,m,k. The next line is to enter the number of M bits. nOutputAshen want to know how many kinds of numbers do not appear unlucky numbers, the result of output modulus K redundancy.Sample Input4 3 100111Sample OutputBayi the puzzl
Advertising:#include int main(){ puts("转载请注明出处[vmurder]谢谢"); puts("网址:blog.csdn.net/vmurder/article/details/44003109");}ExercisesThe process of establishing an AC automaton can be changed to KMP.Anyway single string 233.Code:#include #include #include #include #include #define Tusing namespace STD;intN,m,p;structmrx{intX[T][T];} Ini,std,trs,e; MRXoperator* (ConstMRX a,ConstMRX b) {MRX c=e;intI,j,k; for(i=0; i for(j=0; j for(k=0; kLong Long) a.x[i][k]*b.x[k][j]%p)%=p;returnC;} MRX Power (MR
Design a fairly well-packaged matrix class (easy to use)(mainly at that time the matrix with the struct write, now feel good rotten.) In fact, the use of struct writing is mainly using his = number assignment directly copy memory block, written as class, but also a few more constructors ... )Right as one of your own class design exercises (my oop design sucks ...) ), estimated time of completion: variable (
http://blog.csdn.net/janeky/article/details/17272625Today we're going to talk about rotation in unity. There are three main ways of doing this. Transformation matrices, four-and Euler-angles.Defined
Transformation matrices
You can perform arbitrary 3d transformations (panning, rotating, zooming, trimming) and perspective transformations using homogeneous coordinates. Generally less used. A matrix4x4 matrix class is available in unity
Given an integerN, Generate a square matrix filled with elements from 1N2 in spiral order.
For example,GivenN=3,
You shoshould return the following matrix:
[1, 2, 3], [8, 9, 4], [7, 6, 5]]Algorithm: the algorithm is divided into four directions, with scanning in the upper right and lower left. If you can enter a number, you can change the direction. This question is not difficult, but it is prone to small e
conjunction with the -Superscript textDefinition and Usage:The content contained in the Tip: This tag is useful for adding footnotes to a document and for representing exponential values in equations. If used in conjunction with the underline textDefinition and Usage:The Tips and Comments:Tip: Use with Property:
The cite property points to the URL of a document that explains why the text was inserted or modified.
Example:
Cite properties are not supported by mainst
REDIRECT command actually use a lot of it, just do not look carefully, this wave just again use and empty summed up a wave.See > and >> First:The only difference between the two is that the > is redirected to a file,>>
IO redirection:Output REDIRECT:>features: Overwrite outputOutput REDIRECT:>>Features: Append output# set-csuppresses overwrite output redirection to existing files;You can use the force overwrite output at this time: >|# set +cTurn off the above featuresError output stream redirection: 2&
-(void) Viewwillappear: (BOOL) animated {self. Navigationcontroller. Navigationbarhidden=NO; Deng Chao: Put in willappear, cannot be placed in Viewdidload (because Viewdidload is executed first, then Viewwillappear is executed. And when the controller does not have the dealloc,viewdidload will not be executed) }Execution order:Initwithnibname >>>
multiplication. The same is true for matrix multiplication.For example, in d3d,
D3d is a row vector, row-first storage, OpenGL is a column vector, and column-first storage. Although the same matrix is stored in d3d or OpenGL, the conversion results are the same,Because OpenGL transforms a vector as a column vector and multiply each column of the same matrix to
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.