http://www.lydsy.com/JudgeOnline/problem.php?id=4002

好吧,完全不会做,在考场只能爆零。

膜拜PoPoQQQ大神

#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<utility>
#include<set>
#include<bitset>
#include<vector>
#include<functional>
#include<deque>
#include<cctype>
#include<climits>
#include<complex>
//#include<bits/stdc++.h>适用于CF,UOJ,但不适用于poj using namespace std; typedef unsigned long long ULL;
typedef long long LL;
typedef double DB;
typedef pair<int,int> PII;
typedef complex<DB> CP; #define mmst(a,v) memset(a,v,sizeof(a))
#define mmcy(a,b) memcpy(a,b,sizeof(a))
#define fill(a,l,r,v) fill(a+l,a+r+1,v)
#define re(i,a,b) for(i=(a);i<=(b);i++)
#define red(i,a,b) for(i=(a);i>=(b);i--)
#define ire(i,x) for(typedef(x.begin()) i=x.begin();i!=x.end();i++)
#define fi first
#define se second
#define m_p(a,b) make_pair(a,b)
#define SF scanf
#define PF printf
#define two(k) (1<<(k)) template<class T>inline T sqr(T x){return x*x;}
template<class T>inline void upmin(T &t,T tmp){if(t>tmp)t=tmp;}
template<class T>inline void upmax(T &t,T tmp){if(t<tmp)t=tmp;} const DB EPS=1e-;
inline int sgn(DB x){if(abs(x)<EPS)return ;return(x>)?:-;}
const DB Pi=acos(-1.0); inline int gint()
{
int res=;bool neg=;char z;
for(z=getchar();z!=EOF && z!='-' && !isdigit(z);z=getchar());
if(z==EOF)return ;
if(z=='-'){neg=;z=getchar();}
for(;z!=EOF && isdigit(z);res=res*+z-'',z=getchar());
return (neg)?-res:res;
}
inline LL gll()
{
LL res=;bool neg=;char z;
for(z=getchar();z!=EOF && z!='-' && !isdigit(z);z=getchar());
if(z==EOF)return ;
if(z=='-'){neg=;z=getchar();}
for(;z!=EOF && isdigit(z);res=res*+z-'',z=getchar());
return (neg)?-res:res;
} const ULL Mod=; ULL b,d,n;
ULL res; inline ULL cheng(ULL a,ULL b)
{
ULL res=;
for(;b!=;b>>=){if(b&)res=(res+a)%Mod;a=(a<<)%Mod;}
return res;
} struct Tmatrix
{
int n,m;
ULL v[][];
inline void clear(){n=m=;mmst(v,);}
inline friend Tmatrix operator *(Tmatrix a,Tmatrix b)
{
Tmatrix c;c.clear();
int i,j,k;
c.n=a.n;c.m=b.m;
re(i,,c.n)
re(j,,c.m)
re(k,,a.m)
c.v[i][j]=(c.v[i][j]+cheng(a.v[i][k],b.v[k][j]))%Mod;
return c;
}
}; inline Tmatrix power(Tmatrix a,ULL k)
{
Tmatrix x;x.clear();
x.n=x.m=;
x.v[][]=x.v[][]=;
while(k){if(k&)x=x*a;a=a*a;k>>=;}
return x;
} Tmatrix A; int main()
{
freopen("bzoj4002.in","r",stdin);
freopen("bzoj4002.out","w",stdout);
b=gll();d=gll();n=gll();
if(n==)
cout<<""<<endl;
else
{
A.clear();
A.n=A.m=;
A.v[][]=b;A.v[][]=(d-b*b)/;
A.v[][]=;A.v[][]=;
A=power(A,n-);
res=(cheng(A.v[][],b)+cheng(A.v[][],))%Mod;
if(b*b!=d && !(n&))res--;
res=(res%Mod+Mod)%Mod;
cout<<res<<endl;
}
return ;
}

最新文章

  1. MS SQL 错误:The operation could not be performed because OLE DB provider &quot;SQLNCLI10&quot; for linked server &quot;test&quot; was unable to begin a distributed transaction.
  2. 【转】Python yield 使用浅析
  3. ThinkPHP留后门技巧
  4. ruby -- 基础学习(二) 外键配置实现级联删除
  5. [bzoj1296][SCOI2009]粉刷匠(泛化背包)
  6. Sqoop增量从MySQL中向hive导入数据
  7. 图的强连通分量-Kosaraju算法
  8. html --- VML --- javascript --- 旋转矩形
  9. Mongodb查询的用法,备注防止忘记
  10. solrj6.2异常--Expected mime type application/octet-stream but got text/html.
  11. A Bit Fun
  12. video字幕无法显示,video视频在google中无法控制快进
  13. Android4.0新控件
  14. 从微软MVP到女儿开学--2017前半年小结
  15. 海量数据挖掘MMDS week2: Nearest-Neighbor Learning最近邻学习
  16. 「Android」系统架构概述
  17. [01] AJAX
  18. windows平台,实现录音功能详解
  19. ABP框架入门踩坑-使用MySQL
  20. Django_杂

热门文章

  1. jquery next nextAll nextUntil siblings的区别
  2. (转)pem, cer, p12 and the pains of iOS Push Notifications encryption
  3. X Shell 4配色方案[Solarized Dark]
  4. [React Testing] Element types with Shallow Rendering
  5. [iOS] App引导页的简单实现 (Swift 2)
  6. gcc和g++编译c或者c++文件碰到的问题
  7. linux防火墙开启-关闭
  8. Android WiFiDirect 学习(二)——Service Discovery
  9. spring-security 登陆认证之初次探究
  10. cell高度自动适应文章内容