233 Matrix

有一\(n\times m\)的矩阵\(\{a\}\),定义\(a[0][0]=0,a[0][1]=233,a[0][2]=2333,a[0][3]=23333...\),然后给出\(a[1][0],a[2][0],...,a[n][0]\),未给出或定义的位置满足\(a[i][j]=a[i-1][j]+a[i][j-1]\),询问\(a[n][m]\)的值\(mod\ 10000007\),\(n ≤ 10,m ≤ 10^9\)。

显然对于第0行,我们有转移方程\(a[0][i]=a[0][i-1]\times 10+3\),这个是可以转移的,显然需要增添辅助1,注意到n很小,故考虑整个压维,故设状态矩阵(以n=2为例)

\[\begin{bmatrix}1&a[0][i]&a[1][i-1]&a[2][i-1]\end{bmatrix}
\]

不难得知转移方程

\[\begin{bmatrix}1&3&0&0\\0&10&1&1\\0&0&1&1\\0&0&0&1\end{bmatrix}
\]

于是根据规律,填写转移矩阵和状态矩阵即可。

参考代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#define il inline
#define ri register
#define ll long long
#define yyb 10000007
using namespace std;
struct matrix{
ll jz[12][12];
il void clear(){
memset(jz,0,sizeof(jz));
}
il void unit(){
clear();ri int i;
for(i=0;i<12;++i)jz[i][i]=1;
}
il void print(){
ri int i,j;
for(i=0;i<12;++i,putchar('\n'))
for(j=0;j<12;++j)
printf("%lld ",jz[i][j]);
putchar('\n');
}
il matrix operator*(matrix x){
matrix y;y.clear();
ri int i,j,k;
for(i=0;i<12;++i)
for(j=0;j<12;y.jz[i][j]%=yyb,++j)
for(k=0;k<12;++k)
y.jz[i][j]+=jz[i][k]*x.jz[k][j]%yyb;
return y;
}template<class free>
il matrix operator^(free y){
matrix ans,x(*this);ans.unit();
while(y){
if(y&1)ans=ans*x;
x=x*x,y>>=1;
}return ans;
}
}tran,state;
int main(){
ll n,m;int i,j;
while(scanf("%lld%lld",&n,&m)!=EOF){
state.jz[0][0]=1,state.jz[0][1]=233;
for(i=2;i<=n+1;++i)scanf("%lld",&state.jz[0][i]);
tran.jz[0][0]=1,tran.jz[0][1]=3,tran.jz[1][1]=10;
for(i=2;i<=n+1;++i)
for(j=1;j<=i;++j)
tran.jz[j][i]=1;
state=state*(tran^m);
printf("%lld\n",state.jz[0][n+1]);
tran.clear(),state.clear();
}
return 0;
}

233 Matrix的更多相关文章

  1. [HDU5015]233 Matrix

    [HDU5015]233 Matrix 试题描述 In our daily life we often use 233 to express our feelings. Actually, we ma ...

  2. HDU5015 233 Matrix(矩阵高速幂)

    HDU5015 233 Matrix(矩阵高速幂) 题目链接 题目大意: 给出n∗m矩阵,给出第一行a01, a02, a03 ...a0m (各自是233, 2333, 23333...), 再给定 ...

  3. 233 Matrix(hdu5015 矩阵)

    233 Matrix Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total ...

  4. Spring-1-I 233 Matrix(HDU 5015)解题报告及测试数据

    233 Matrix Time Limit:5000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Descript ...

  5. 233 Matrix(矩阵快速幂+思维)

    In our daily life we often use 233 to express our feelings. Actually, we may say 2333, 23333, or 233 ...

  6. ACM学习历程——HDU5015 233 Matrix(矩阵快速幂)(2014陕西网赛)

    Description In our daily life we often use 233 to express our feelings. Actually, we may say 2333, 2 ...

  7. HDU - 5015 233 Matrix(杨辉三角/前缀+矩阵快速幂)

    233 Matrix In our daily life we often use 233 to express our feelings. Actually, we may say 2333, 23 ...

  8. HDU5015 233 Matrix —— 矩阵快速幂

    题目链接:https://vjudge.net/problem/HDU-5015 233 Matrix Time Limit: 10000/5000 MS (Java/Others)    Memor ...

  9. HDU 5015 233 Matrix(网络赛1009) 矩阵快速幂

    先贴四份矩阵快速幂的模板:http://www.cnblogs.com/shangyu/p/3620803.html http://www.cppblog.com/acronix/archive/20 ...

  10. hdu 5015 233 Matrix (矩阵高速幂)

    233 Matrix Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Tota ...

随机推荐

  1. bat命令自用其(一)

    每秒钟打印ping命令结果到指定文件: @echo off set /p ip=Input the IP required to monitor: :starts echo %date% %time% ...

  2. Hbase启动的时候出现:[RpcServer.handler=28,port=60000] ipc.RpcServer: RpcServer.handler=28,port=60000: exiting,master.HMasterCommandLine: Master exiting

    hadoop 版本:CDH5.02 Hbase 版本:hbase-0.96.1.1-cdh5.0.2 配置文件:hbase-site.xml <configuration> <pro ...

  3. java-day15

    File类 文件和目录路径名的抽象表示,主要用于文件和目录的创建.查找和删除等操作 静态成员 static String pathSeparator 路径分隔符 File.pathSeparator ...

  4. mysql 需要掌握的重点

    1. 安装mysql:     google it.2. 新建database,table: create database database_name;create table table_name ...

  5. IQueryable 和 IEnumerable(二)

    IQueryable 和 IEnumerable的扩展方法 一  我们从ef的DbSet<T>看起来,我们看到他继承了IQueryable<T> 和 IEnumerable&l ...

  6. Redhat镜像-RHEL-官方镜像下载大全

    原网站内容链接:https://pan.baidu.com/s/12XYXh#list/path=%2F 已经存在自己的云盘上了

  7. git连接gitee笔记

    #首先参照 https://blog.csdn.net/zhangyu4863/article/details/80427289 #然后需要注意,在办公室无法使用 git remote add ori ...

  8. 【JZOJ6384】珂学家

    description analysis 注意配出来的饮料不可以再配成其他饮料,所以肯定有\(O(n^2)\)的枚举 而且可口度两两互不相同,搞得我以为这是神仙题 考虑把两个试剂\([l_1,r_1] ...

  9. 校园商铺-4店铺注册功能模块-3thumbnailator图片处理和封装Util

    1. 初步使用thumbnailator 1.1 下载依赖 <!-- https://mvnrepository.com/artifact/net.coobird/thumbnailator - ...

  10. 10月23日——作业1——while循环练习

    while循环'''此类编程题,注意带进去试一试1.九九乘法表row=1while row<=9: col=1 while col<=row: print(col,"*" ...