link:-https://ide.codingblocks.com/s/2218
this is the code explained in the video …
as explained in previous video in our F1 vector of K*1
we put smaller value above and larger value below like
first as F[i-k] then F[i-k-1] then F[i-k-2]…so on F[i]
but then the ans is last index of resultant vector after multiplying T and F1 vector …
but here F1 vector value are store in reverse of what i stated
and result as
ll res = 0;
for(int i=1;i<=k;i++){
res = (res + (T[1][i]*F1[i])%MOD)%MOD;
}
ON LINE :- 101
PLZ CLEAR MY DOUBT
Matrix Exponentiation------------
Hey @riprogerdep
Your query isn’t clear. Can you please frame it better.
Also please use reference variable when passing vector<vector> to avoid TLE
The values in F are stored in order F[1], F[2], F[3] and so on F[k]
And try to write this down on a piece of paper and dry run the algo, things might be clearer that way