博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【AC自动机】【矩阵乘法】【等比数列】hdu2243 考研路茫茫——单词情结
阅读量:6944 次
发布时间:2019-06-27

本文共 1180 字,大约阅读时间需要 3 分钟。

题解:http://blog.csdn.net/xingyeyongheng/article/details/10005923

这里采用了二分法求等比数列前n项和。

等比数列前n项和也可以用矩乘快速幂来求[a 1]    [Sn]    =    [Sn+1]

                    [0 1]    [a  ]          [   a   ]

#include
#include
#include
#include
#include
using namespace std;typedef unsigned long long ull;typedef vector
vec;typedef vector
mat;typedef pair
Point2;typedef pair
Point;int N;mat I;mat operator * (const mat &a,const mat &b){ mat c(N,vec(N)); for(int i=0;i
>1); if(n&1) return Point(t.first*t.first*a,t.second*(t.first*a+1)); else return Point(t.first*t.first,(t.second-t.first)*(t.first*a+1)+t.first);}Point2 sum_A_n(mat a,ull n){ if(n==0) return Point2(I,I); Point2 t=sum_A_n(a,n>>1); if(n&1) return Point2(t.first*t.first*a,t.second*(t.first*a+I)); else return Point2(t.first*t.first,(t.second-t.first)*(t.first*a+I)+t.first);}queue
q;int child[40][26],fail[40],size=1;bool word[40];void Insert(char S[]){ int len=strlen(S); int now=0; for(int i=0;i
>n>>m){ Init(); for(int i=1;i<=n;++i) { scanf("%s",s); Insert(s); } build(); for(int i=0;i

转载于:https://www.cnblogs.com/autsky-jadek/p/6504500.html

你可能感兴趣的文章
Linux常用命令 (包含Apache, MySQL)
查看>>
admob 广告增加
查看>>
客户/服务器程序设计范式
查看>>
由一个Xml序列化操作看mscorlib.dll 2.0、4.0 String的Trim方法实现
查看>>
Cainteoir Text-to-Speech 0.8 发布
查看>>
【WP7】绘图与保存
查看>>
Solr拼写检查(spellCheck)配置和使用
查看>>
javascript 中cookie的存储,获取cookie,删除cookie的方法
查看>>
jquery中的scrollTop()和scrollLeft()应该怎么用?【转】
查看>>
flag标志寄存器
查看>>
Android Notification与Toast(一)
查看>>
搜索引擎lucene
查看>>
UVA11991
查看>>
linux:php配置文件php.ini详解
查看>>
有用和有趣的产品秤砣
查看>>
PhotoShopCS5
查看>>
EVENT 10051:"trace OPI calls"
查看>>
利用Oracle在线重定义Online Redefinition清理历史数据
查看>>
A.3-C# 面向对象编程
查看>>
Linux下高性能网络编程中的几个TCP/IP选项
查看>>