Codeforces 575A. Fibonotci 矩阵乘法+线段树
题解: 这道题……看完题就大概知道怎么做,但是考试时没有实现出来。 考试的时候想的是用倍增来实现,但是细节太多写不出来,正解是用线段树来维护连续n个矩阵的乘积,其实这个做法也挺显然的,但是没有把这两个东西放在一起用过。然后细节还是很多,调了一下午。 代码: #include<bits/stdc++.h> using namespace std ; #define LL long long #define pa pair<int,int> const int Maxn= 50010 ; const int inf= 2147483647 ; LL read() { LL x= 0 ,f= 1 ; char ch=getchar(); while (ch< '0' ||ch> '9' ){ if (ch== '-' )f=- 1 ;ch=getchar();} while (ch>= '0' &&ch<= '9' )x=(x<< 3 )+(x<< 1 )+(ch^ 48 ),ch=getchar(); return x*f; } struct Node{LL pos,bel; int v;}a[Maxn]; bool cmp(Node a,Node b){ return a.pos<b.pos;} LL K,belK; int P,n,m,s[Maxn],F[Maxn]; struct