HDU6050-Funny Function
来源:互联网 发布:银行存款怎样划算知乎 编辑:程序博客网 时间:2024/06/05 09:32
多校好难啊补题吧。。。。
看了题解发现有些东西不清楚啊。。。。
对于任意i>=1,当j>=3时,有 通过归纳法可以得到
来推推吧:
1. 当 i=1时显然成立,
2. 假设当 i= k-1时成立
3. 当 i=k时
F i-1,j = F i-1,j-1 + 2*F i-1,j-2
= F i-1,j-1 + F i-1,j-2 + F i-1,j-3 + 2*F i-1,j-4
= F i-1,j-1 + F i-1,j-2 + F i-1,j-3 + ………… + 2* Fi-1,j-n (n为偶)
F i-1,j - Fi-1,j-n = F i-1,j-1 + F i-1,j-2 + F i-1,j-3 + ………… + Fi-1,j-n = F i,j-n
Fi,j-n = F i-1,j - Fi-1,j-n
Fi,j-n-1 = F i-1,j-1 - Fi-1,j-n-1
Fi,j-n-2 = F i-1,j-2 - Fi-1,j-n-2
因为 F i-1, j = F i-1,j-1 + 2 * F i-1,j-2
因为 Fi-1,j-n = Fi-1,j-n-1 + 2 * Fi-1,j-n-2
所以 Fi,j-n = Fi,j-n-1 + 2 * Fi,j-n-2
所以 Fi,j = Fi,j-1 + 2 * Fi,j-2
综上所述
(推导不是很严谨)
Fi,j+1 = Fi,j + Fi,j-1+…………+2*Fi,1 (j为偶)
Fi,j+1 = Fi,j + Fi,j-1+…………+2*Fi,2+Fi,1-Fi,1 (j为奇)
同理 我们易可以得到
接着这个就不必多解释了吧,
还是推推吧
#include<stdio.h>#include<iostream>#include<string.h>using namespace std; #define N 1000000007struct node{long long a[2][2];}; const node A={0,2,1,1};const node B0={1,0,0,1};const node B1={-1,2,1,0};const node A0={1,1,0,0};node cheng(node x,node y){node c;memset(c.a,0,sizeof(c.a));for(long long i=0;i<2;i++)for(long long j=0;j<2;j++)for(long long k=0;k<2;k++)c.a[i][j]=(c.a[i][j]+(x.a[i][k] * y.a[k][j])%N)%N;return c;}node jian(node x,node y){node c;c.a[0][0]=x.a[0][0]-y.a[0][0];c.a[0][1]=x.a[0][1]-y.a[0][1];c.a[1][0]=x.a[1][0]-y.a[1][0];c.a[1][1]=x.a[1][1]-y.a[1][1];return c;}node qc(node a,long long b){node c;c.a[0][0]=c.a[1][1]=1;c.a[0][1]=c.a[1][0]=0;while(b){if(b&1)c=cheng(c,a);a=cheng(a,a);b>>=1;}return c;}int main(){long long n,m;int t;scanf("%d",&t);while(t--){ scanf("%lld%lld",&n,&m);node d=A;d=qc(d,n);if(n&1) d=jian(d,B1);else d=jian(d,B0);d=cheng(A0,qc(d,m-1));cout<<d.a[0][0]<<endl;}return 0; }
有这么个公式,不知道怎么推的,还在想,想到在补
F(m,1)=(2*k1^(m-1)+(1+(-1)^(m+1))/2)/3 其中k1=(2^n-1);
- HDU6050-Funny Function
- HDU6050-Funny Function
- HDU6050 Funny Function[矩阵快速幂]
- hdu6050 Funny Function【打表+找规律+矩阵快速幂】
- Hdu6050 Funny Function(2017多校第2场)
- 2017多校训练Contest2: 1006 Funny Function hdu6050
- 2017杭电多校联赛第二场-Funny Function (hdu6050)快速幂解数学方程
- 2017多校训练第二场 hdu6050 Funny Function(数学+快速幂+逆元)
- Funny Function————(hdu6050)矩阵快速幂
- Funny Function
- hdu6050
- 多校6050 Funny Function
- HDU 6050 Funny Function
- hdu 6050 Funny Function
- 1006.Funny Function
- hdu 6050 funny function
- HDU-6050 Funny Function
- 问题 Funny Function
- bzoj4080 Wf2014 Sensor Network 随机化
- 多校赛2017 R2
- Ajax基础
- iReport默认参数和变量的含义解析【转】
- Python入门系列——第13篇
- HDU6050-Funny Function
- 小知♂识 除法取模 逆元♂
- Spring Boot(一):HelloWorld
- bzoj2160 拉拉队排练 manacher+差分
- Android流行UI布局——底部导航(BottomNavigationView+ViewPager+Fragment)
- linux文件概览
- Codeforces Gym 100814 G It is all about wisdom 二分+最短路
- J2EE入门
- Redis的图形界面管理监控工具的安装及使用