当前位置:网站首页>HDU4565 So Easy! [matrix multiplication] [derivation]
HDU4565 So Easy! [matrix multiplication] [derivation]
2022-07-27 14:12:00 【51CTO】
Topic link :
http://acm.hdu.edu.cn/showproblem.php?pid=4565
The main idea of the topic :
Definition Sn = [( a + √b )^n] % m,[x] Express x Rounding up , such as [3.14] = 4. Here you are. a b n m Value ,
seek Sn How much is the .
Ideas :
This is a classic question , because (a-1)^2< b < a^2, therefore 0 < |a-√(b)| < 1, therefore
Sn = [( a + √b )^n] % m = ( [( a + √b )^n] + [( a - √b))^n] ) % m.
That is, the right is actually an integer , If you expand the binomial on the right , Except for the offsetting part , The rest is all
Integers . This formula sets An = (a + √b)^n,Bn = (a - √b)^n,Cn = [An],Sn = Cn % m.
First ask Cn The recurrence formula of .
set up Cn = pC(n-1) + qC(n-2), The characteristic equation is x^2 = p*x + q, from [( a + √b )^n] + [( a - √b))^n]
It can be seen that the characteristic roots are a + √b and a - √b. be p = 2*a,q = b - a^2.
be Cn = 2*a*C(n-1) + (b-a^2)C(n-2). Then start to construct the matrix
[ Cn ] = [ 2*a b-a^2 ] * [C(n-1)]
[C(n-1)] [ 1 0 ] [C(n-2)]
[ Cn ] = [ 2*a b-a^2 ] ^(n-2) * [C2]
[C(n-1)] [ 1 0 ] [C1]
From top Sn The formula shows ,C2 = 2*(a^2 + b),C1 = 2*a.
Then we use the fast power of matrix to get Cn, Then the output is OK .
AC Code :
边栏推荐
- 第3章业务功能开发(添加线索备注,自动刷新添加内容)
- Accuracy improvement method: efficient visual transformer framework of adaptive tokens (open source)
- 【2022-07-25】
- Unity2d -- camera follow
- [training day4] sequence transformation [thinking]
- 认知篇----硬件工程师的成才之路之经典
- Deep confidence network (DBN) [the classical DBN network structure is a deep neural network composed of several layers of RBM (restricted Boltzmann machine) and one layer of BP]
- Advanced MySQL III. storage engine
- In the "meta cosmic space", utonmos will open the digital world of the combination of virtual and real
- There is no need for semantic segmentation of annotation data! Eth & Leuven University proposed maskdistill, using transformer for unsupervised semantic segmentation, SOTA
猜你喜欢

Cognition -- classic of the road to success of hardware engineers

认知篇----硬件工程师的成才之路之经典

Electronic bidding procurement mall system: optimize traditional procurement business and speed up enterprise digital upgrading

阿里最新股权曝光:软银持股23.9% 蔡崇信持股1.4%

面向流行性疾病科普的用户问题理解与答案内容组织

基于C语言实现线性表的建立、插入、删除、查找等基本操作

基于RoBERTa-wwm动态融合模型的中文电子病历命名实体识别

融合迁移学习与文本增强的中文成语隐喻知识识别与关联研究

基于在线问诊记录的抑郁症病患群组划分与特征分析

Mining enterprise association based on Enterprise Knowledge Map
随机推荐
Weice biological IPO meeting: annual revenue of 1.26 billion Ruihong investment and Yaohe medicine are shareholders
The salary level of programmers in various countries is a little miserable
阻塞队列BlockingQueue
Zhishang technology IPO meeting: annual revenue of 600million, book value of accounts receivable of 270Million
HDU4496 D-City【并查集】
CARLA 笔记(04)— Client 和 World (创建 Client、连接 World 、批处理对象、设置 Weather、设置 Lights、World snapshots)
Onnxruntime [reasoning framework, which users can easily use to run an onnx model]
What open source projects of go language are worth learning
In the "meta cosmic space", utonmos will open the digital world of the combination of virtual and real
基于C语言的LR1编译器设计
基于C语言实现线性表的建立、插入、删除、查找等基本操作
Excellent basic methods of URL parsing using C language
Why does script file 'd:\anaconda3\envs\pad appear_ env\Scripts\pip-script. py‘ is not present.
Various ways to use new
Small program completion work wechat campus laundry small program graduation design finished product (2) small program function
在灯塔工厂点亮5G,宁德时代抢先探路中国智造
Wechat campus laundry applet graduation design finished product (6) opening defense ppt
A Keypoint-based Global Association Network for Lane Detection
Ncnn compilation and use pnnx compilation and use
HDU4565 So Easy!【矩阵连乘】【推导】