HDU 1757 A Simple Math Problem 【矩阵经典7 构造矩阵递推式】

HDU1757 - A Simple Math Problem - 矩阵快速幂 1.题目描述 A Simple Math Problem Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4507    Accepted Submission(s): 2716 Problem Descripti 阅读详情

任意门:http://acm.hdu.edu.cn/showproblem.php?pid=1757

A Simple Math Problem

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 6621    Accepted Submission(s): 4071


Problem Description
Lele now is thinking about a simple function f(x).

If x < 10 f(x) = x.
If x >= 10 f(x) = a0 * f(x-1) + a1 * f(x-2) + a2 * f(x-3) + …… + a9 * f(x-10);
And ai(0<=i<=9) can only be 0 or 1 .

Now, I will give a0 ~ a9 and two positive integers k and m ,and could you help Lele to caculate f(k)%m.
 

 

Input
The problem contains mutiple test cases.Please process to the end of file.
In each case, there will be two lines.
In the first line , there are two positive integers k and m. ( k<2*10^9 , m < 10^5 )
In the second line , there are ten integers represent a0 ~ a9.
 

 

Output
For each case, output f(k) % m in one line.
 

 

Sample Input
10 9999 1 1 1 1 1 1 1 1 1 1 20 500 1 0 1 0 1 0 1 0 1 0
 

 

Sample Output
45 104
 

 

Author
linle
 

 

题意概括:

按照题目所给的递推式求解 f(N);

解题思路:

根据递推式构造矩阵乘法;

然后矩阵快速幂解决矩阵乘法;

 

 

Ac code:

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define LL long long
using namespace std;
const int N = 11;
int Mod, K;

struct mat
{
    int m[15][15];
}base, tmp, ans;

mat muti(mat a, mat b)
{
    mat res;
    memset(res.m, 0, sizeof(res.m));
    for(int i = 1; i <= N; i++)
    for(int j = 1; j <= N; j++){
        if(a.m[i][j]){
            for(int k = 1; k <= N; k++){
                res.m[i][k] = (res.m[i][k] + a.m[i][j] * b.m[j][k])%Mod;
            }
        }
    }
    return res;
}

mat qpow(mat a, int n)
{
    mat res;
    memset(res.m, 0, sizeof(res.m));
    for(int i = 1; i <= N; i++) res.m[i][i] = 1LL;
    while(n){
        if(n&1){
            res = muti(res, a);
        }
        a = muti(a, a);
        n>>=1;
    }
    return res;
}

int main()
{

    while(~scanf("%d%d", &K, &Mod)){
        memset(base.m, 0, sizeof(base.m));
        for(int i = 0; i < 10; i++){
            base.m[i][1] = i;
        }

        memset(tmp.m, 0, sizeof(tmp.m));
        for(int i = 1; i <= 10; i++){
            tmp.m[i][i+1] = 1;
        }
        for(int i = 10; i >= 1; i--){
            scanf("%d", &tmp.m[10][i]);         //构造递推关系矩阵
            base.m[10][1] += ((LL)(i-1)*tmp.m[10][i])%Mod;
        }
        //see see
//            for(int i = 1; i <= 10; i++){
//                for(int j = 1; j <= 10; j++){
//                    printf("%d ", tmp.m[i][j]);
//                }
//                puts("");
//            }

        if(K <= 10){
            printf("%d\n", base.m[K][1]);
        }
        else{
            tmp = qpow(tmp, K-10);
            ans = muti(tmp, base);
//            //see see
//            for(int i = 1; i <= 10; i++){
//                for(int j = 1; j <= 10; j++){
//                    printf("%d ", tmp.m[i][j]);
//                }
//                puts("");
//            }
            printf("%d\n", ans.m[10][1]%Mod);
        }
    }
    return 0;
}

 

新手必看:瑞萨MCU选型时,QFP、QFN、BGA这些封装到底该怎么选?(附选型避坑指南) 本文详细解析了瑞萨MCU选型中QFP、QFN、BGA等封装的特点与适用场景,提供实战避坑指南。通过对比封装的空间占用、散热能力、焊接难度等核心维度,帮助工程师根据具体需求选择最合适的芯片封装,避免因选型不当导致的高成本与生产问题。 阅读详情

相关推荐

FPGA实战:用DDR3和乒乓操作解决视频帧撕裂问题(附Verilog代码)

本文详细介绍了如何利用DDR3内存和乒乓操作架构解决FPGA视频处理中的帧撕裂问题。通过多帧缓存原理、AXI接口配置和自适应乒乓操作设计,有效隔离读写操作,确保视频流稳定传输。文章包含Verilog代码实现和性能优化技巧,适用于工业相机、医疗影像等高速视频处理场景。

m2n3b4v5c6的博客 291

CSimplemathproblem ---- 牛客网

输入两个正整数X, Y。老师给了你两个正整数X, Y。并按照一下规则做运算,求出答案Z。如果X是Y的因数,则Z等于X + Y。否则Z = Y - X。这一节课,Priest给大家做了一个小测试。

m0_67717626的博客 568

RK3566/RK3588 NPU性能实测:用mobilenet模型快速验证你的开发板NPU是否正常工作

本文提供了RK3566/RK3588开发板NPU性能实测指南,通过MobileNet模型快速验证NPU是否正常工作。详细介绍了环境搭建、测试资源获取、编译运行及结果分析的全流程,帮助开发者高效验证神经网络加速器功能,为后续AI应用部署奠定基础。

weixin_28826521的博客 449

C语言刷牛客竞赛新手入门——选择结构--(1)

牛客竞赛:题目链接:https://ac.nowcoder.com/acm/contest/19304?

weixin_55511545的博客 776

AD9253 LVDS 高速ADC驱动开发

对应:data clock时钟为500M DDR mode。具体内容:下文的参考博客写的很清楚,我就不详细写了。参考博客clock align模块不完整,本文新增这个模块。3、该款ADC工作在125Msps下,14bit - 2Lane - 1frame 模式。2、查阅Xilinx xapp524手册。1、查阅AD9253器件手册。

CAOXUN_FPGA的博客 2110

嵌入式GUI显示驱动配置实战:从emWin硬件接口到SPI屏驱动优化

在嵌入式系统开发中,显示驱动是连接GUI库与物理屏幕的核心底层模块,其本质是CPU与显示控制器之间的数据“翻译”与“传输”系统。其工作原理是通过实现特定的硬件抽象层接口,将GUI生成的图形数据转换为屏幕能识别的时序和协议。这项技术的核心价值在于,它允许开发者在资源受限的MCU上,通过适配不同的硬件接口,以最小的硬件开销实现稳定的图形输出。其典型应用场景包括智能家居面板、工业HMI、可穿戴设备等嵌入式图形界面开发。本文将深入解析emWin GUI库的驱动框架,重点探讨如何针对SPI、I2C等串行接口进行高效的

weixin_29159711的博客 343

牛客-语法入门-循环结构程序设计 2022.10.5

负数进制转换规则:如果余数mod为负数,余数mod减去除数base进制基数,之后数字n减去余数mod再除以进制基数base,循环往复即可。记录上下限求取差值,还需要前缀和进行差值累加。

Ls_attack的博客 303

2025年开源气象大模型的实现原理与实践指南

气象大模型在人工智能时代实现了革命性突破,通过深度学习技术以更低的计算成本达到甚至超越传统数值天气预报的精度。开源气象大模型的出现使得全球研究者和机构都能参与气象AI的创新。本文详细解析了开源气象大模型的实现原理,包括核心架构、数据准备、训练方法和实际预测流程,并提供了实践指南。核心架构主要采用Transformer、图神经网络和扩散模型,处理多模态数据融合和时空联合建模。数据体系构建涉及数据来源、预处理和增强策略。模型训练关键技术包括损失函数设计、分布式训练优化和训练过程监控。微调与领域适应策略包括迁移学

专注AI大模型,软件混淆,授权 1183

A Simple Math Problem HDU - 1757(递推构造矩阵快速幂)

Lele now is thinking about a simple function f(x). If x < 10 f(x) = x. If x >= 10 f(x) = a0 * f(x-1) + a1 * f(x-2) + a2 * f(x-3) + …… + a9 * f(x-10); And ai(0<=i<=9) can only be 0 or 1 . N...

wait 239

视源CVTE嵌入式面试题及参考答案(200+面试题,17万字)

内核模块如何设置? 内核模块是可在运行时动态加载到内核或从内核卸载的代码块。以下是设置内核模块的步骤: 首先,编写内核模块代码。通常使用 C 语言编写,包含必要的头文件,如<linux/init.h>、<linux/module.h>等。在代码中,需要定义模块的初始化函数和清理函数。初始化函数在模块加载时被调用,用于进行模块的初始化工作,如注册设备、分配资源等。清理函数在模块卸载时被调用,用于释放资源、注销设备等。 例如: #include <li

大模型大数据攻城狮的专栏 2205

CSP - 2024 普及组初赛试题及解析

CSP - 2024 普及组初赛试题及解析

QD_Jason的博客 2911

hdu1757 A Simple Math Problem(矩阵乘法)

Problem Description Lele now is thinking about a simple function f(x). If x  If x >= 10 f(x) = a0 * f(x-1) + a1 * f(x-2) + a2 * f(x-3) + …… + a9 * f(x-10); And ai(0 Now, I will give a0 ~ a9 a

天亮说晚安 2408

使用xlwings在Python中对Excel表格进行操作是非常方便的,可以实现自动化处理、批量数据处理等功能

使用xlwings在Python中对Excel表格进行操作是非常方便的,可以实现自动化处理、批量数据处理等功能。本篇文章主要介绍如何使用xlwings对Excel表格进行多行多列数据设置和操作,并给出相应的源代码。接着,我们可以对这个范围内的所有单元格进行操作,如设置字体颜色、填充颜色、对齐方式等。以上就是使用xlwings对Excel表格进行多行多列数据操作和设置字体颜色、填充色和对齐方式的全部内容。最后,我们可以将数据写入到单元格中,也可以从单元格中读取数据。在Excel中,可以通过。

BUG?不存在的! 714

Simple Math Problem HDU - 1757 (矩阵快速幂)

Simple Math Problem 题目链接:HDU - 1757 题意:定义了一个函数:f(x);If x &lt; 10 f(x) = x. If ...

Sirius_han的博客 323

深度学习工具包 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")

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

hdu1757 - A Simple Math Problem

大牛牛们说,这是矩阵快速幂,入门的题, 也是很模板的一道题吧 我先慢慢理理, 1.先是快速幂取模(百度文库有一篇超详细的推导  求得是a^b mod c(是关于数的) int pow(int a, int b, int c) {     int ans = 1;     a = a % c;     while(b>0)     {        if(b&1)//判断b是否

Jeromiewn的博客 876

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

hdu 1757 A Simple Math Problem(矩阵连乘)

题意:http://acm.hdu.edu.cn/showproblem.php?pid=1757 f[10]=(a0,a1,a2,a3,a4,a5,a6,a7,a8,a9)*(9,8,7,6,5,4,3,2,1,0)' f[11]=(a0,a1,a2,a3,a4,a5,a6,a7,a8,a9)*(f[10],9,8,7,6,5,4,3,2,1)' f[n]=(a0,a1,a2,a3,a4,

theArcticOcean 1044

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

HDU 1757 A Simple Math Problem

题意:给出a0~a9和k、m, f(x) = a0 * f(x-1) + a1 * f(x-2) + a2 * f(x-3) + …… + a9 * f(x-10);求f(k)%m。 思路: 矩阵A              矩阵B0 1 0 0 0 0 0 0 0 0        f0 ...

bancaidun1539的博客 126

hdu1757 - A Simple Math Problem 矩阵快速幂

今天学矩阵突然开窍了总结一下就是,矩阵乘法是没有实际意义的 (这里的意思是,在现实中找不到对应的东西,这是一个纯数学方法) 而且把原本普通算数可以做的事情转变成矩阵乘法是多此一举 比如说把点(x,y)左右平移10个单位,非常简单地可以想到变换后的坐标是(x+10,y)或者(x-10,y)。那为什么要用一个矩阵去表示这种变换呢?因为矩阵乘法有结合律! 说点实际例子。 假设不使用矩阵乘法,那么平

做题的地方 695

hdu 1757 A Simple Math Problem (构造矩阵解决递推式问题)

题意:有一个递推式f(x) 当x < 10 f(x) = x.当 x >= 10 f(x) = a0 * f(x-1) + a1 * f(x-2) + a2 * f(x-3) + …… + a9 * f(x-10) 同时ai(0<=i<=9) 不是 0 就是 1; 现在给你 ai 的数字,以及k和mod,请你算出 f(x)%mod 的结果是多少 ...

104

HDU 1757 A Simple Math Problem(矩阵快速幂)

题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1757 思路:直接递推肯定超时,比赛的时候就想着找规律,如何把递推式转化为f1到f9的和规律,想炸了,没想到时矩阵快速幂,能把时间压为log(n),不会超时,代码也很好写 AC代码: #include #include #include #include #include #includ

Java识堂,一个有干货的微信公众号 316

HDU1757 A Simple Math Problem 矩阵乘法

因为 If x If x >= 10 f(x) = a0 * f(x-1) + a1 * f(x-2) + a2 * f(x-3) + …… + a9 * f(x-10); 所以根据递推式构造关系构造递推矩阵,与vijos1067的本质一样,注意上方的ai与f(i)是反的,这里我已开始没注意查了一会。 A Simple Math Problem Time Limit: 3000/100

722

hdu A Simple Math Problem 1757 矩阵的构造和快速幂

一道矩阵乘法的题目,做了这道题,让我稍微开拓了一点点思维。题意很简单,给你一个函数,如果x 如果x > 10, f(x) = a0 * f(x-1) + a1 * f(x-2) + a2 * f(x-3) + …… + a9 * f(x-10); a0,a1。。。。a9是常数,题目输入会给出。 做这个题目首先了解下矩阵。有两个矩阵A B,他们的乘积也是一个矩阵C,c[i][j]等于A矩阵

a549875231的专栏 719

hdu1757 A Simple Math Problem(矩阵快速幂)

题目: A Simple Math Problem Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3522    Accepted Submission(s): 2130 Problem Description L

hexiecs的技术专栏 951

HDU 1757 A Simple Math Problem(构造矩阵)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1757 题意:给定函数f(x)。若x&lt;10则f(x)=x,否则f(x)=a0*f(x-1)+a1* f(x-2)+a2*f(x-3)+ …… +a9*f(x-10)。求f(n)%m. 思路:构造矩阵a[0][i]=ai,a[i][i-1]=1,(0&lt;=i&lt;=9),求a的n-9次方。...

weixin_33982670的博客 81

【矩阵乘法】hdu hdoj 1757 A Simple Math Problem

这题是比较典型的矩阵乘法的题目。矩阵乘法的一个用处就是计算常系数线性齐次递推关系,例如菲波衲契数列。 具体请看 http://blog.youkuaiyun.com/cclsoft/archive/2010/05/13/5586549.aspx要注意的地方有如何确定mm矩阵的pow数。还有mm矩阵的初始化。特别是第0行的那些,是代表系数如F(n) = a*F(n-1)+b*F(n-2)+c

xiaoc's home 1530

Hdu 1757 A Simple Math Problem

A Simple Math Problem Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1352    Accepted Submission(s): 778 Problem Description Lele now

Magic__ 701
上一篇: VOJ1049 送给圣诞夜的礼品 【矩阵经典4】
下一篇: VOJ1067 【矩阵经典7 构造矩阵】
莜莫oO
博客等级 码龄9年 7粉丝 226原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值