【矩阵快速幂】code forces 631E

Codeforces 185A - Plant(矩阵快速幂) 【含彩蛋!】一年后,“向上”的三角形植物分成四个三角形植物:其中三个指向“向上”,一个指向“向下”。再过一年,每个三角形植物分成四个三角形植物:其中三个方向与母植物相同,一个方向相反。这样不仅能把非常大的指数给不断变小,所需要执行的循环次数也变小,而最后表示的结果却一直不会变。帮助小矮人找出n年内有多少“向上”的三角形植物,输出除以1000000007(1e9+7)的余数。 O(log₂N), 与朴素的O(N)相比效率有了极大的提高。... 阅读详情

【矩阵快速幂】code forces 631E

【题目链接】


题目内容

There are b blocks of digits. Each one consisting of the same n digits, which are given to you in the input. Wet Shark must choose exactly one digit from each block and concatenate all of those digits together to form one large integer. For example, if he chooses digit 1 from the first block and digit 2 from the second block, he gets the integer 12.

Wet Shark then takes this number modulo x. Please, tell him how many ways he can choose one digit from each block so that he gets exactly k as the final result. As this number may be too large, print it modulo 109 + 7.

Note, that the number of ways to choose some digit in the block is equal to the number of it’s occurrences. For example, there are 3 ways to choose digit 5 from block 3 5 6 7 8 9 5 1 1 1 1 5.

Input
The first line of the input contains four space-separated integers, n, b, k and x (2 ≤ n ≤ 50 000, 1 ≤ b ≤ 109, 0 ≤ k < x ≤ 100, x ≥ 2) — the number of digits in one block, the number of blocks, interesting remainder modulo x and modulo x itself.

The next line contains n space separated integers ai (1 ≤ ai ≤ 9), that give the digits contained in each block.

Output
Print the number of ways to pick exactly one digit from each blocks, such that the resulting integer equals k modulo x.

Examples
input
12 1 5 10
3 5 6 7 8 9 5 1 1 1 1 5
output
3
input
3 2 1 2
6 2 2
output
0
input
3 2 1 2
3 1 2
output
6
Note
In the second sample possible integers are 22, 26, 62 and 66. None of them gives the remainder 1 modulo 2.

In the third sample integers 11, 13, 21, 23, 31 and 33 have remainder 1 modulo 2. There is exactly one way to obtain each of these integers, so the total answer is 6.


解题思路

题目大意是给一个大小为n的数组([1,9]),取b个数可重复的数连起来,比如取1和2会得到12,取2和2会得到22。求取得的数连起来对x取模得到k的种类数。取位置不同但值相同的数视为不同种类。
首先,记录一下1,2,3……出现的次数,记为num[i];
接下来一个一个数取,用dp[i][j]表示取好第i个数后%x==j的种类数,比如第i个数取k,对答案的贡献是dp[i+1][ (j*10+k) % x]=dp[i][j] * num[k];
dp[0][0]初始化为1;
不考虑复杂度的话就是

for(i=0;i<b;i++)
    for(j=0;j<x;j++)
        for(k=0;k<x;k++)
            dp[i+1][(j*10+k)%x]=dp[i][j]*num[k];

用矩阵快速幂来优化。
矩阵大概长
[ dp[0][0],dp[0][1],dp[0][2],……dp[0][x] ]*[某矩阵的(b)次幂] = [ dp[n][0],dp[n][1],dp[n][2],……dp[n][x] ]
这样。


AC代码

#include <bits/stdc++.h>
#define LL long long
using namespace std;

const int maxn=3007;
const int INF=0x3f3f3f3f;
const LL mod=1e9+7;
const int maxarr=100;///矩阵最大大小

LL m;///矩阵实际大小
LL num[107];
struct node
{
    LL arr[maxarr][maxarr];
};
void init(node &a)
{
    for(LL i=0;i<m;i++)
        for(LL j=0;j<m;j++)
            a.arr[i][j]=0;
}
node MatrixMultiplication(node &a,node &b)
{
    LL i,j,k;
    node c;
    init(c);
    for(i=0;i<m;i++)
        for(j=0;j<m;j++)
            for(k=0;k<m;k++)
                c.arr[i][j]=(c.arr[i][j]+a.arr[i][k]*b.arr[k][j])%mod;
    return c;
}
node fast_power(node a,LL n)
{
    node b;
    init(b);
    for(int i=0;i<maxarr;i++)
        b.arr[i][i]=1;
    while(n>0)
    {
        if(n&1==1) b=MatrixMultiplication(a,b);
        a=MatrixMultiplication(a,a);
        n>>=1;
    }
    return b;
}

int main()
{
    LL n,B,K,x,y,i,j,k;
    scanf("%lld%lld%lld%lld",&n,&B,&K,&x);
    m=x;
    for(i=1;i<=n;i++)
    {
        scanf("%lld",&y);
        num[y%x]++;
    }
    node a,b;
    init(a);
    for(j=0;j<x;j++)
    {
        for(k=0;k<x;k++)
        {
            a.arr[j][(j*10+k)%x]+=num[k];
        }
    }
    b=fast_power(a,B);
    init(a);
    a.arr[0][0]=1;
    a=MatrixMultiplication(a,b);
    printf("%lld\n",a.arr[0][K]);
    return 0;
}


RK3588开发笔记-spi扩展canfd芯片MCP2518FD调试笔记 在嵌入式系统开发中,CANFD(控制器局域网灵活数据速率)是一种广泛应用于汽车和工业自动化领域的通信协议。为了满足项目需求,我们在RK3588平台上通过SPI接口扩展了CANFD芯片MCP2518FD,之所以用spi进行canfd扩展,是为了解决原生RK3588原生can不够稳定的问题(发送扩展帧有几率编程标准帧,RK3568/3588均存在该问题)。通过本次调试工作,我们成功地在RK3588平台上扩展了CANFD芯片MCP2518FD,并实现了与CAN总线的稳定通信。 阅读详情

相关推荐

Zynq-PS-SDK(12) 之 VDMA+VTC+AXI4S-VideoOut 视频通路硬件搭建

前面分别叙述了《Zynq-PS-SDK(9) 之 VDMA》、《Zynq-PS-SDK(10) 之 VTC》以及《Zynq-PS-SDK(11) 之 AXI4-Stream To Video Out》;搭建一个简单的视频通路(Framebuffer -> HDMI)就要用到这些个模块,总体的设计框图如下所示: 视频数据的 Framebuffer 在 DDR 中,通过 Processing System 写入进去; 数据通过高带宽的 AXI4 接口(这里用到了 HP AXI,即 64bits 带

StephenZhou 5601

练习codeforces最好的10个建议【翻译】

原文链接:https://www.geeksforgeeks.org/10-best-tips-to-get-started-with-codeforces/最近刚从实验室退出,想锻炼一下自己的算法能力,看到这篇文章比较好,分享一下。

douhuanmin123的博客 1661

CHNS数据库下载与使用指南:从申请到导入的全流程解析

面板数据是经济学与公共卫生实证研究的重要支撑。中国健康与营养调查(CHNS)自1989年持续追踪中国居民的家庭与个人健康、营养及经济行为,为研究者提供了跨度近三十年的纵向微观数据。理解CHNS的数据组织原理与申请机制,是高效利用该数据的前提。该数据广泛适用于健康经济学、膳食营养分析及公共政策评估等场景。围绕CHNS的下载流程,完整梳理了注册申请、数据文件解析以及Stata、R、Python三种工具的读取方法,并针对邮箱验证、文件损坏、ID匹配等常见问题提供排查建议,帮助研究者快速建立数据处理基础。

weixin_33624741的博客 294

CF631E Product Sum(斜率优化dp)

题目大意: 一个数组的价值为∑i=1nai⋅i\sum_{i=1}^{n}a_i \cdot i∑i=1n​ai​⋅i,必须执行以下操作一次: 将一个数移到某个位置 使数组的价值最大 解题思路: 将lll位置的元素移到rrr位置: △l,r=(al⋅r+al+1⋅l+...+ar⋅(r−1))−(al⋅l+al+1⋅(l+1)+...+ar⋅r)=al⋅(r−l)−(al+1+al+2+...+ar)\bigtriangleup_{l,r}=(a_l\cdot r+a_{l+1}\cdot l + .

trouble_的博客 326

基于Active-HDL的HDL设计录入与仿真

作者:毛茏玮 / Saint 掘金:https://juejin.im/user/5aa1f89b6fb9a028bb18966a 微博:https://weibo.com/5458277467/profile?topnav=1&amp;wvr=6&amp;is_all=1 GitHub:github.com/saint-000 CSDN: https://me.csdn.net/qq_4053...

一个会写代码的烤鸭 7790

[案例四] 智能填写属性工具(支持装配组件还有建模实体属性的批量创建、编辑)

本次案例主要是对上次导出自动导出BOM的一个前处理,要想导出属性,首先的有属性。于是本着学习的态度进行制作,可能有些功能有点别扭(支持装配环境下组件属性的批量填写,支持建模环境下的实体(不包括装配组件实体)——为了减负我把其过滤掉了,一般没人会往装配体里添加进行建模吧,但是不免有奇葩,哈哈哈)。

weixin_47753171的博客 1986

CodeForces - 1117D 矩阵快速幂

CodeForces - 1117D 矩阵快速幂题意思路代码 题目链接 题意 一个长度为n的串全是1,问有多少种方式用0替换1满足0的长度正好为m(可以没有) 思路 如果当前位置放1的话可以直接从前一位转移过来,如果放0的话则从i-m+1到i应该都是1,即从i-m转移过来。所以f[i]表示到第i位的方案数,则转移方程为f[i] = f[i-1] + f[i-m]。由于n很大所以做矩阵优化。 [fn...

jesHrz的博客 580

绿米Aqara S1【妙控开关 S1E】版本降级或升级自定义固件的方法

绿米Aqara S1【妙控开关 S1E】版本降级或升级自定义固件的方法

LeeKwen的专栏 2204

CodeForces 631E Product Sum(斜率优化DP+二分|三分)

题意:给出n个数,现在可以移动一个数的位置,现在要使和sigma(ai*i)最大,询问这个最大和。 思路:将一个数向左移动和向右移动是一样的,现在考虑向左移动。 先预处理出前缀和,将一个数向左移动后,那么改变量为sum[r-1]-sum[l-1]+a[r]*(r-l),考虑枚举r,那么和r有关的数据就变成了常量。 现在问题转化成了求a[r]*l-sum[l-1],注意到这里l和sum[l-]

GODSPEED 1344

深入浅出:大型语言模型(LLM)的全面解读

在当今的数字化时代,人工智能技术已经成为各行各业的核心驱动力之一。而在人工智能的领域中,大型语言模型(LLM)作为一种引人瞩目的技术,正在以其强大的语言理解和生成能力引领着一场革命。本文旨在深入浅出地解读大型语言模型,探讨其背后的原理、技术突破、应用场景以及未来发展趋势。

fudaihb的博客 10万+

一点击打印电脑就卡死?资源管理器停止工作的解决方法

Windows11共享的HP1022n打印机导致客户端打印时资源管理器崩溃卡死,电脑停止工作。

gary18的专栏 615

CodeForces-450B-矩阵快速幂

很经典的矩阵快速幂,这个题也可以求循环节 #include &lt;cstring&gt; #include &lt;cstdio&gt; #include &lt;iostream&gt; #include &lt;vector&gt; #include &lt;algorithm&gt; #include &lt;queue&gt; #define INF 0x3f3f3f3f usi...

alusang的博客 316

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

Codeforces训练(1900-2100)

文章目录前言CF1475G Strange BeautyCF1475F Unusual Matrix 前言 最近codeforce打的不是很好,所以专门进行一次训练,下面题目的难度全在1900−21001900-21001900−2100难度区间。 CF1475G Strange Beauty 题目链接:CF1475G Strange Beauty 题目大意:给定一个数组,求最少删去多少个数,使得剩下的所有元素互相整除。 数据范围:1≤t≤10,1≤n≤2∗105,1≤a[i]≤2∗1051\le t\le

lin_rany的博客 1217

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

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

codeforces训练(rating1400-1800)

Educational Codeforces Round 90 (Rated for Div. 2) D. Maximum Sum on Even Positions 解题思路:首先将问题的多种不同情况列出来,发现有两种情况。 这种数组的问题好像经常会有差分数组的构造。,下次解不出来构造一下差分数组。 由于求的是连续的,所以构造差分数组,后求连续子段和,并且复杂度是O(n),满足。 #include <bits/stdc++.h> using namespace std; const int N

zhoucheng_123的博客 945

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

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

Codeforces 训练计划

这篇文章前面先说明一下接下去的一项计划: 出于当前本人代码质量不高导致时常WA多发才过,思维不够敏捷导致水题也不能快速做过,本人需要一些针对性的计划来训练。 1、初始训练题量为100题,要求为codeforce上Div2的C题以上 2、由于A、上下界B、大小于符号C、题目看错,翻译错误D、其他非思维因素的简单错因的WA,都需要假一罚五,一题可以重复。具体多少罚款不随题目难度增加而减少,一律五题。 3、周一至少两题,周二三题,周三一题,周四两题,周五两题,周六五题,周日五题,不包括日常训练与其他比赛的题目,仅

shordinger的博客 1010

codeforces 631E Product Sum (dp凸单调性)

#include #include #include #include #include #include #include #include #include #include #include using namespace std; #pragma comment(linker, "/STACK:1024000000,1024000000") #define inf 0x3f3f3f3f

To_c_t_w 774

CodeForces - 631E

知识点:三分+凸包 三分法就是取区间的两个三等分点,然后不断逼近,时间复杂度是O(log3/2n) 凸包就是单峰函数(可上可下),三分就是对严格凸包做逼近操作(要规定精度)。 下面的代码还没到弄明白,以后再说吧: #include<bits/stdc++.h> #define rep(i,x,y) for (int i=(x);i<=(y);i++) #define l...

Ivanzn的博客 361

Codeforces 631E Product Sum 斜率优化

我们先把问题分成两部分, 一部分是把元素往前移, 另一部分是把元素往后移。对于一个 i 后的一个位置, 我们考虑前面哪个移到这里来最优。 我们设最优值为val, val = max(a[ j ] * (i - j) - (sum[ i ] - sum[ j ])我们能发现这个能转换成斜率优化的形式如果 j 比 k 更优且 j > k 我们能得到, ((j * a[ j ...

190

Codeforces 631E:Product Sum

E. Product Sum time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Blake is the boss of Kris, however, this does

1214

凸包+三分 Codeforces631E roduct Sum

传送门:这里写链接内容 题意:允许交换两个位置位置的数字,最终使得∑nii∗A[i]\sum_i^ni*A[i] 最大,求最大值 思路:我们列出式子,很明显的可以发现可以用斜率优化来做。 但是我们发现A数组并不是不递减的,所以我们不能用单调队列来维护。 对于这题,我们应该去维护下凸包,然后在凸包上二分来做。 但是在做的时候,发现有非常多的细节要处理,必须非常细心才行#include <ma

qwb的博客 777

[codeforces631E]Product Sum

E. Product Sum time limit per test: 1 second memory limit per test: 256 megabytes input:standard input output:standard output Blake is the boss of Kris, however, this doesn't spoil th...

weixin_30369041的博客 236

codeforces 621 E. Wet Shark and Blocks(dp+矩阵快速幂)

Description There are b blocks of digits. Each one consisting of the same n digits, which are given to you in the input. Wet Shark must choose exactly one digit from each block and concatenate all of...

so_so_y的博客 441

codeforces621E————Wet Shark and Blocks(动态规划,矩阵快速幂)

E. Wet Shark and Blocks time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There are b blocks of digits. Each

say_c_box的博客 507

Codeforces 691E Xor-sequences(矩阵加速DP)

题目链接 Xor-sequences 利用矩阵加速。 先预处理出当序列长度为$2$的时候的方案数。 也就是说这个序列起点是$a[i]$终点是$a[j]$且中间没有任何元素。 但是所求的$k$很大,序列长度远远不止$2$。这个时候就要考虑乘法原理。 然后利用矩阵乘法来模拟乘法原理,那么就用到了矩阵快速幂。 #include <bits/stdc++.h> using...

weixin_30885111的博客 167

S - DNA Alignment CodeForces - 520C(思维 + 简单矩阵快速幂)

题意 有两个字符串 s、t,定义 h (s, t) 为 s 与 t 中 字符串相同的位置的个数, 定义 : 其中 shift (t, j) 表示将 t 循环向左移动 j 位,形成一个新的字符串 t′t't′ 思路 代码 #include <iostream> #include <stdio.h> #include <string.h> #include <math.h> #include <algorithm> #include <st

做一只熊猫不好吗? 246

codeforces 719E (线段树 + 矩阵快速幂)

E. Sasha and Array time limit per test 5 seconds memory limit per test 256 megabytes input standard input output standard output Sasha has an array of integersa1, a2, ..., an. You have to pe...

PCCCCC的博客 314
上一篇: POJ 1742 coins (奇怪的多重背包)
下一篇: 【dfs 组合数】code forces 991E Bus Number
xuziling_
博客等级 码龄9年 1粉丝 58原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值