国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

線段樹

2019-11-08 02:34:10
字體:
來源:轉載
供稿:網友
#include <iostream> #include <cstring> #include <cstdio> #include <algorithm> #include <iomanip> #include <cmath> typedef long long ll; using namespace std; struct jz {     ll node[2][2]; }ans,mid; ll n,t,mod; jz cheng(jz a,jz b) {     jz temp;     for(int i=0;i<2;i++)     {         for(int j=0;j<2;j++)        {         temp.node[i][j]=0;         for(int k=0;k<2;k++)          {           temp.node[i][j]=(temp.node[i][j]+a.node[i][k]*b.node[k][j])%mod;          }         }      }      return temp; } void csh() {     ans.node[0][0]=ans.node[1][1]=1;     ans.node[0][1]=ans.node[1][0]=0;     mid.node[0][0]=mid.node[0][1]=mid.node[1][0]=1;     mid.node[1][1]=0; } inline ll pw(ll b) {     csh();     while(b>0)     {         if(b&1)ans=cheng(ans,mid);         mid=cheng(mid,mid);         b>>=1;     }     return ans.node[0][1]; } int main() {     scanf("%lld",&t);     for(int i=1;i<=t;i++)     {         scanf("%lld %lld",&n,&mod);         PRintf("%lld/n",pw(n));     }     return 0; } /*inline void cot(int x,int y,bool z){    if(x){        fa[x]=y;    }    if(y){        son[y][z]=x;    }}inline void rot(int x,bool z){    int xx=fa[x],xxx=fa[xx];    cot(son[x][z],xx,z^1);    cot(x,xxx,son[xxx][1]==xx);    cot(xx,x,z);}void splay(int x,int y){    int xx=fa[x],xxx=fa[xx];    while(xx!=y){        if(xxx==y){            rot(x,son[xx][0]==x);        }else{            bool z=son[xxx][0]==xx;            if(son[xx][z]==x){                rot(x,z^1);                rot(x,z);            }else{                rot(xx,z);                rot(x,z);            }        }        xx=fa[x],xxx=fa[xx];    }    if(!y){        rt=x;    }}*/
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 台南县| 肃宁县| 南丰县| 鄂托克前旗| 沾益县| 南城县| 双江| 城步| 汉川市| 梅河口市| 高平市| 常山县| 静安区| 宜君县| 灵寿县| 黄骅市| 杭锦后旗| 岳阳县| 大悟县| 肇东市| 开原市| 大洼县| 泽普县| 科尔| 宝兴县| 崇义县| 竹山县| 平和县| 墨玉县| 南昌市| 浪卡子县| 肥东县| 从江县| 敖汉旗| 乌拉特后旗| 石台县| 原平市| 浪卡子县| 巨鹿县| 九龙城区| 图木舒克市|