【BZOJ3240】[NOI2013]矩阵游戏

计算机视觉与深度学习实战:以Python为工具,基于帧间差法进行视频目标检测 计算机视觉是一门研究如何使机器从数字图像或视频中提取、分析和理解有用信息的学科。它涉及图像处理、计算机图形学、人工智能等多个领域的知识。通过计算机视觉技术,我们可以实现图像的识别、分类、目标检测等功能。本文介绍了计算机视觉与深度学习的基本概念和原理,并以Python为工具,基于帧间差分法实现了视频目标检测。帧间差分法具有算法实现简单、程序设计复杂度低、对光线等场景变化不太敏感等优点,因此在实际应用中得到了广泛的应用。然而,帧间差分法也存在一些局限性,如对于缓慢移动或静止的物体检测效果不佳。 阅读详情

题目链接

题目描述

求一个矩阵的第n行m列
递推式

F[1][1]=1F[i,j]=a∗F[i][j−1]+b(j!=1)F[i,1]=c∗F[i−1][m]+d(i!=1) F [ 1 ] [ 1 ] = 1 F [ i , j ] = a ∗ F [ i ] [ j − 1 ] + b ( j ! = 1 ) F [ i , 1 ] = c ∗ F [ i − 1 ] [ m ] + d ( i ! = 1 )

对10^9+7 取模

n m巨大 10^1000000

Sol

先把转移到行尾的矩阵给他幂出来
然后乘上一个到下一行的转移矩阵,在幂个n-1次,然后在乘上转移到行尾的矩阵
这题就秒了

然而数据比较恶心

O(数的长度)转二进制? 不存在的

听说可以强行手动推式子用欧拉定理降幂?

推了一大堆后放弃(菜 TAT)

居然可以直接欧拉定理降次数后递推?
递推次数也能取模?(Orz)

于是就一脸懵逼地过了

原理?大概是因为最后的式子也是很多个幂相加的形式,所以就可以取模?(雾)

注意欧拉定理要求互质,所以当a或c等于1的话不能 modϕ(p) m o d ϕ ( p ) 而要直接 modp m o d p ,因为此时是线性相加的东西,这个取模的正确性还比较显然…

代码:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<cstdlib>
#include<set>
#define Set(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
const int mod=1e9+7;
struct matrix{
    int a[2][2];
    inline void clear(){Set(a,0);return;}
    inline int* operator [](int x){return a[x];}
    inline matrix operator *(matrix b){
        matrix c;c.clear();
        for(register int k=0;k<2;++k)
            for(register int i=0;i<2;++i)
                for(register int j=0;j<2;++j)
                    c[i][j]=(c[i][j]+1ll*a[i][k]*b[k][j]%mod)%mod;
        return c;
    }
}S,T1,T2;
const int N=1e6+10;
char sn[N],sm[N];
int ln,lm;
int n,m;
int a,b,c,d;
inline matrix matrix_POW(matrix A,ll k)
{
    if(k==1) return A;
    matrix c;c.clear();
    c[0][0]=c[1][1]=1;
    while(k>0){
        if(k&1) c=c*A;
        A=A*A;
        k>>=1;
    }
    return c;
}
inline void Turn(char s[],int len,int &to,int MO)
{
    to=0;
    for(register int i=1;i<=len;++i) to=(1ll*to*10+s[i]-'0')%MO;
}
int main()
{
    scanf("%s",sn+1);scanf("%s",sm+1);
    ln=strlen(sn+1);lm=strlen(sm+1);
    scanf("%d %d %d %d",&a,&b,&c,&d);
    if(a==1) Turn(sn,ln,n,mod);else Turn(sn,ln,n,mod-1);
    if(c==1) Turn(sm,lm,m,mod);else Turn(sm,lm,m,mod-1);
    T1[0][0]=a;T1[1][0]=b;T1[1][1]=1;
    T2[0][0]=c;T2[1][0]=d;T2[1][1]=1;
    S[0][0]=1;S[0][1]=1;
    T1=matrix_POW(T1,m-1);
    T2=T1*T2;T2=matrix_POW(T2,n-1);
    S=(S*T2)*T1;
    printf("%d\n",S[0][0]);
}
量化交易新手必看:如何用vnpy+Tushare轻松获取A股历史数据(附完整代码) 本文为量化交易新手提供了使用vnpy和Tushare构建A股历史数据获取系统的完整指南。通过详细的代码示例,手把手教你搭建环境、封装数据获取引擎,并实现日线等数据的格式转换与本地存储,为策略回测与分析奠定坚实的数据基础。 阅读详情

相关推荐

基于Arduino与Velostat的智能鞋垫:DIY足底压力监测系统全解析

压力传感器是物联网和健康监测领域的基础元件,其核心原理是将物理压力转换为可测量的电信号。通过压阻效应,材料的电阻值随压力变化,从而实现压力感知。这项技术为低成本、定制化的健康监测方案提供了可能,尤其在运动分析和康复训练中具有重要价值。本文聚焦于利用Velostat压敏材料和Arduino平台,详细解析如何从传感器制作、信号调理到无线数据传输,构建一套完整的足底压力监测系统。文中深入探讨了传感器阵列构建、信号滤波等关键技术,并针对常见问题提供了实用的解决方案,为创客和开发者实现可穿戴健康监测设备提供了清晰的工

weixin_32818781的博客 402

[NOI2013]矩阵游戏

题意:对于一个n行m列的矩阵,第i行第j列的元素为F[i][j]。已知a, b, c, d,并且矩阵元素满足: F[1][1] = 1 F[i,j] = a * F[i][j-1] + b (j!=1) F[i,1] = c * F[i-1][m] + d (i!=1) 求F[n][m] 答案对1e9 + 7取模 1 &lt;= n, m &lt;= 1e1000000 1 &lt;= a, b,...

CH_Vaniteux的博客 330

[记录一个bug]av_hwdevice_ctx_create出现Cannot allocate memory(附带库运行时路径)[已解决]

新写的程序里调用ffmpeg的av_hwdevice_ctx_create()这个函数,出现Cannot allocate memory。但是另个程序一样的代码,居然是成功的。 反复检查之后无果,就跳出去查了一下,看到一个问答: Have you tried to use ffmpg executables with the same libs that you using when you run the app? Have you tried to use ffmpg executables

熊猫Ben的博客 3586

P1397 [NOI2013]矩阵游戏(递推)

P1397 [NOI2013]矩阵游戏 一波化式子,$f[1][m]=a^{m-1}+b\sum_{i=0}^{m-2}a^i$,用快速幂+逆元求等比数列可以做到$logm$ 设$v=a^{m-1},k=\sum_{i=0}^{m-2}a^i$ 那么$f[1][m]=v+bk$ 再对纵列化一波式子,$f[i][m]=f[i-1][m]*vc+bk+vd$ 如果你直接上个矩乘可以...

dingqiongliang0363的博客 305

【Flutter 面试题】 怎么减少Widget的重新构建?

关于 const 关键字的使用:在 Flutter 开发中,任何时候当你确定一个 Widget 在其整个生命周期内都不会发生变化时,使用 const 关键字声明这个 Widget。这样的声明告诉 Flutter 框架这个 Widget 可以在编译时生成,后续的构建周期中可以重用已经创建的 Widget,从而避免了重复的构建开销。这适用于静态文本、图标或整个不变的 Widget 树。

Code Metaverse 1577

车载网络测试实操源码_使用CAPL解析VBF文件

VBF(Versatile Binary Format)文件是一种二进制文件格式,被沃尔沃、福特、马自达、吉利等汽车制造商广泛采用。这种格式无法使用我们常规的烧录器进行刷写,通常需要进行解析转化。如果各位需要自己编写软件或脚本来刷写VBF文件,或者需要对刷写功能进行测试时,那么本篇文章就会对你非常有用。今天我们就来讲一下如何使用CAPL脚本对VBF文件进行数据解析。VBF文件包含三部分:VBF版本段、文件头段、数据段。前面的版本段和文件头段是ASCII码,包含版本、地址、校验码等信息

文章主要涉及嵌入式软件开发、测试、项目管理等,欢迎交流,共同进步。 2997

BZOJ3240[Noi2013]矩阵游戏——矩乘优化递推+费马小定理

Description 婷婷是个喜欢矩阵的小朋友,有一天她想用电脑生成一个巨大的n行m列的矩阵(你不用担心她如何存储)。她生成的这个矩阵满足一个神奇的性质:若用F[i][j]来表示矩阵中第i行第j列的元素,则F[i][j]满足下面的递推式: F[1][1]=1 F[i,j]=a*F[i][j-1]+b (j!=1) F[i,1]=c*F[i-1][m]+d (i!=1) 递推式中a,b,...

stevensonson的博客 484

华为OD机试双机位C卷-几何平均值最大子数组(Py/Java/C/C++/Js/Go)

华为OD机试(机考)2026双机位C卷 【几何平均值最大子数组】,提供C语言、Java、C++、Python、Go、JavaScript源码实现,并提供完整思路讲解,以及在线OJ模拟做题。华为OD机试真题【几何平均值最大子数组】。

qq_45776114的博客 1367

BZOJ 3240 [Noi2013] 矩阵游戏 题解

【原题】

阿蒋的专栏 4130

数字滤波器应用介绍

线性滤波器FIR ,会引起恒定延迟,通过补零的方式补偿非线性滤波器IIR,会引起频率相关的延迟,通过零相位延迟filtfilt补偿从信号中去除不需要的频谱时,通过滤波和补偿实现。如果需要去除的频率与采样率相差甚远,比如4kHz 与100Hz, 可通过 低通滤波->补偿->降采样–> 滤波 补偿 -->上采样还原的方法。*降采样前一定要先低通滤波为了防止混叠。

weixin_39107270的博客 274

数据库小技能:数据导入脚本

背景:版本大升级,从2.0升级到3.0 ,服务端开发语言从c#换到java语言。数据库类型从microsalft sql server 换到mysql。数据来源于微信,用于查询卡bin。

专注于计算机研发知识和资讯分享 774

bzoj3240 [NOI2013]矩阵游戏

bzoj3240 [NOI2013]矩阵游戏 有一个递推式 \(f_{i,\ j}\) 满足: \[\begin{cases}f_{1,\ 1}=1\\f_{i,\ j}=a\times f_{i,\ j-1}+b&(j\neq1)\\f_{i,\ 1}=c\times f_{i-1,\ m}+d&(i\neq1)\end{cases}\] 求 \(f_{n,\ m} \bmod...

weixin_30505485的博客 86

ROS机器人未知环境自主探索功能包explore_lite最全源码详细解析(一)

本系列文章主要针对ROS机器人常使用的未知环境自主探索功能包explore_lite展开全源码的详细解析,并进行概括总结。 本系列文章共包含六篇文章,前五篇文章主要介绍explore_lite功能包中 explore.cpp、costmap_tools.h、frontier_search.cpp、costmap_client.cpp等源码实现文件中全部函数的详细介绍,第六篇文章进行概括总结,包含自主探索功能包explore_lite的简介,实现未知环境自主探索功能的原理及流程总结,效果演示,使用功能包

慕羽★的博客 3937

BZOJ3240: [Noi2013]矩阵游戏

http://www.lydsy.com/JudgeOnline/problem.php?id=3240 Description 婷婷是个喜欢矩阵的小朋友,有一天她想用电脑生成一个巨大的n行m列的矩阵(你不用担心她如何存储)。她生成的这个矩阵满足一个神奇的性质:若用F[i][j]来表示矩阵中第i行第j列的元素,则F[i][j]满足下面的递推式: F[1][1]=1 F[i,j]=a

Unknown 1309

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

BZOJ3240 [Noi2013]矩阵游戏

本文版权归ljh2000和博客园共有,欢迎转载,但须保留此声明,并给出原文链接,谢谢合作。 本文作者:ljh2000作者博客:http://www.cnblogs.com/ljh2000-jump/转载请注明出处,侵权必究,保留最终解释权! Description 婷婷是个喜欢矩阵的小朋友,有一天她想用电脑生成一个巨大的n行m列的矩阵(你不用担心她如何...

dgoh41514的博客 241

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

[BZOJ3240][Noi2013]矩阵游戏 && 快速幂

当我知道这题矩阵可以用费马小定理搞快速幂的时候 我眼泪都要落下来了QAQ 首先求一发通项F[1][1]->F[2][1]的通项 然后写成A+B的形式 若a != 1        A = (a^(m-1))*c        B = b*((a^(m-1))/(a-1)) * c + d 若a == 1        A = c        B = B * (m-1) * c +

shiyukun1998的专栏 1458

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

[BZOJ3240][NOI2013]矩阵游戏

Description 婷婷是个喜欢矩阵的小朋友,有一天她想用电脑生成一个巨大的n行m列的矩阵(你不用担心她如何存储)。她生成的这个矩阵满足一个神奇的性质:若用F[i][j]来表示矩阵中第i行第j列的元素,则F[i][j]满足下面的递推式: F[1][1]=1 F[i,j]=a*F[i][j-1]+b (j!=1) F[i,1]=c*F[i-1][m]+d (i!=1) ...

alu3503的博客 176

[题解]bzoj3240(NOI2013)矩阵游戏

Description婷婷是个喜欢矩阵的小朋友,有一天她想用电脑生成一个巨大的n行m列的矩阵(你不用担心她如何存储)。她生成的这个矩阵满足一个神奇的性质:若用F[i][j]来表示矩阵中第i行第j列的元素,则F[i][j]满足下面的递推式:F[1][1]=1 F[i,j]=a*F[i][j-1]+b (j!=1) F[i,1]=c*F[i-1][m]+d (i!=1) 递推式中a,b,c,d都是

Saramanda的博客 947

bzoj3240: [Noi2013]矩阵游戏

看题目名:矩阵乘法。。。 有公式:x^a=x^(a%phi(p)+phi(p)) (mod p) 因为np,mp互质,可令n=n%phi(p),m=m%(phi(p)). 同一行内可构造矩阵A,设F[i][1]*A'=F[i][m]。 行末到下一行首可构造矩阵B,F[i][1]*B'=F[i+1][1]。 可求得Ans。 #include #include #include

miaom的博客 789

【BZOJ】【3240】【NOI2013】矩阵游戏

十进制快速幂+矩阵乘法+常数优化   听说这题还可以强行算出来递推式……然后乘乘除除算出来……   然而蒟蒻选择了一个比较暴力的做法= =   我们发现这个递推的过程是线性的,所以可以用矩阵乘法来表示,$x=a*x+b$这样一个递推式我们可以这样表示:$$\begin{bmatrix} x& 1 \end{bmatrix} * \begin{bmatrix} a& 0 \...

weixin_30613433的博客 141

BZOJ 3240: [Noi2013]矩阵游戏

3240: [Noi2013]矩阵游戏 Time Limit:10 SecMemory Limit:256 MBSubmit:1586Solved:698[Submit][Status][Discuss] Description 婷婷是个喜欢矩阵的小朋友,有一天她想用电脑生成一个巨大的n行m列的矩阵(你不用担心她如何存储)。她生成的这个矩阵满足一个神奇的性质:若用F[...

weixin_30639719的博客 99

[Luogu P1397] [BZOJ 3240] [NOI2013]矩阵游戏

洛谷传送门 BZOJ传送门 题目描述 婷婷是个喜欢矩阵的小朋友,有一天她想用电脑生成一个巨大的nnn行mmm列的矩阵(你不用担心她如何存储)。她生成的这个矩阵满足一个神奇的性质:若用F[i][j]F[i][j]F[i][j]来表示矩阵中第iii行第jjj列的元素,则F[i][j]F[i][j]F[i][j]满足下面的递推式: F[1][1]=1F[1][1]=1F[1][1]=1 ...

LPA的博客 290

BZOJ3240-NOI2013矩阵游戏

题解: 很多人都用矩乘来AAA这道题,但据说矩乘可能会超时………………。 当a=1a=1a=1时: F[i][j]=F[i][1]+(j−1)∗bF[i][j]=F[i][1]+(j−1)∗bF[i][j] = F[i][1] + (j − 1) ∗ b F[i+1][1]=c∗F[i][1]+(j−1)∗b∗c+dF[i+1][1]=c∗F[i][1]+(j−1)∗b∗c+dF[i ...

Mi-Queen 385

[BZOJ3240][NOI2013]矩阵游戏(数论+矩乘)

可以发现,对于任意一个1≤i≤n1≤i≤n, 从f[i][1]f[i][1]到f[i][m]f[i][m]的转移为f[i][m]=am−1f[i][1]+b∑m−2j=0ajf[i][m]=a^{m-1}f[i][1]+b\sum_{j=0}^{m-2}a^j。 先考虑快速求得am−1a^{m-1}的值,考虑到n,m<=101000000n,m<=10^{1000000}的数据范围,直接快速幂是

女装的你,如此好看! 424

【BZOJ】3240: [Noi2013]矩阵游戏

题意 给出\(n, m(1 \le n, m \le 10^{1000000})\),求\(f(n, m) \ \mod \ 10^9+7\) $$ \begin{cases} f(1, 1) = 1 \\ f(i, 1) = cf(i-1, m) + d \\ f(i, j) = af(i, j-1) + b & (j \neq 1) \end{cases} $$ 其中\(...

118

bzoj 3240 [Noi2013]矩阵游戏

bzoj   3240 传送门: http://www.lydsy.com/JudgeOnline/problem.php?id=3240 Description 婷婷是个喜欢矩阵的小朋友,有一天她想用电脑生成一个巨大的n行m列的矩阵(你不用担心她如何存储)。她生成的这个矩阵满足一个神奇的性质:若用F[i][j]来表示矩阵中第i行第j列的元素,则F[i][j]满足下面的

DJS_K_D的专栏 596
上一篇: 【LuoguP2056】捉迷藏(动态点分治)
下一篇: 【BZOJ3143】[HNOI2013]游走
NeosKnight
博客等级 码龄9年 21粉丝 151原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值