当前位置: 首页 > news >正文

免费淘宝网站建设今日十大头条新闻

免费淘宝网站建设,今日十大头条新闻,哪家网站遴选做的比较好,网站建设工作标准K - 子串翻转回文串2020ccpc河南省赛字符串哈希:将字符串变成x进制数对公式的理解:举个十进制数的例子:123456h[1]1;h[2]1*10212;h[3]12*103123;h[4]123*1041234;.........h[i]h[i-1]*xa[i];h[i]代表的恰巧是整个数的前缀用p[i]表…

K - 子串翻转回文串

2020ccpc河南省赛

字符串哈希:将字符串变成x进制数

对公式的理解:

举个十进制数的例子:123456

h[1]=1;

h[2]=1*10+2=12;

h[3]=12*10+3=123;

h[4]=123*10+4=1234;

.........

h[i]=h[i-1]*x+a[i];

h[i]代表的恰巧是整个数的前缀

用p[i]表示进制数的 i 次方;

想要单取出3-5的子串的值345

步骤;

1,先取出前缀12345(q[5])

2,再减去12000:(h[2]*1000);

取子串哈希值的公式为:h[r]-h[l-1] *(r-l+1);

本题思路:

去掉前缀后缀相同的部分,剩余的前缀或后缀必定要翻转一次

判法:正反跑一次哈希(下标不变权值翻转)

--------------------------------------> 正向权值整串s1

----------> 正向权值翻转部分s2

<---------- 反向权值翻转部分s3

<-------------------------------------- 正向权值整串s4

判法:比较翻转前与翻转后的整串的哈希制是否一样

long long get1(int l,int r)

{

if(l==0) return h1[r];

return ((h1[r]%mod-h1[l-1]*p[r-l+1]%mod)+mod)%mod;/*注意负数取模*/

}

求正向的字符串的hash值

long long get2(int l,int r)

{

return (h2[l]%mod-h2[r+1]*p[r-l+1]%mod+mod)%mod;

}

求反向的字符串的hash值

反向之后如12345中的5是最高位,如求1-3的话我们就应该让a[1]-a[4]*10的(r-l+1)次方

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1e9+7;
const int INF=0x3f3f3f3f;
const int N = 5e5+10;
int st[N];int ed[N];int p[N];
int base=131;
#define ios ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
int get1(int l,int r)
{return (st[r]-st[l-1]*p[r-l+1]%mod+mod)%mod;
}
int get2(int l,int r)
{return (ed[l]-ed[r+1]*p[r-l+1]%mod+mod)%mod;
}
bool check(int l,int r,int len)
{int dex = (st[len] - get1(l, r) * p[len - r] % mod + get2(l, r) * p[len - r] % mod + mod) % mod;/*从s1中取出s2放入s3所得出整串的哈希值*/int dey = (ed[1] - get2(l, r) * p[l - 1] % mod + get1(l, r) * p[l - 1] % mod + mod) % mod;/*从s4中取出s3放入s2所得出整串的哈希值*/    return dex == dey;
}
void solve()
{string s;cin>>s;int len=s.size();s=" "+s;int f=1;for(int i=1;i<=len/2;i++){if(s[i]!=s[len-i+1]){f=0;break;}} if(f==1){cout<<"Yes"<<endl;return ;}else{int pos;for(int i=1;i<=len;i++){if(s[i]!=s[len-i+1]){pos=i;break;}}p[0]=1;for(int i=1;i<=len;i++){st[i]=(st[i-1]*base%mod+s[i])%mod;    p[i]=p[i-1]*base%mod;}ed[len+1]=0;for(int j=len;j>=1;j--){ed[j]=(ed[j+1]*base%mod+s[j])%mod;}for(int i=pos;i<=len-pos+1;i++){int l=pos,r=i;int ll=i,rr=len-pos+1;if(check(l,r,len)||check(ll,rr,len)){cout<<"Yes"<<endl;return ;}    }    }cout<<"No"<<endl;
}
signed main()
{ios;int t;cin>>t;while(t--){solve();}
}


文章转载自:
http://confiscable.gthc.cn
http://samaritan.gthc.cn
http://necessitous.gthc.cn
http://skibobber.gthc.cn
http://shaddup.gthc.cn
http://iodophor.gthc.cn
http://stridulant.gthc.cn
http://awag.gthc.cn
http://po.gthc.cn
http://interjacent.gthc.cn
http://unhallowed.gthc.cn
http://jensenism.gthc.cn
http://kilobaud.gthc.cn
http://discombobulate.gthc.cn
http://stiffly.gthc.cn
http://emphasize.gthc.cn
http://stockist.gthc.cn
http://monument.gthc.cn
http://usgs.gthc.cn
http://quietus.gthc.cn
http://implode.gthc.cn
http://incoercible.gthc.cn
http://omissible.gthc.cn
http://gazebo.gthc.cn
http://semipolitical.gthc.cn
http://antimechanized.gthc.cn
http://semibasement.gthc.cn
http://secondhand.gthc.cn
http://banksia.gthc.cn
http://aeciospore.gthc.cn
http://extempore.gthc.cn
http://winningness.gthc.cn
http://ophiology.gthc.cn
http://craterization.gthc.cn
http://centurial.gthc.cn
http://nonintrusion.gthc.cn
http://orgone.gthc.cn
http://convolute.gthc.cn
http://icky.gthc.cn
http://bomber.gthc.cn
http://aeroallergen.gthc.cn
http://obtain.gthc.cn
http://telegu.gthc.cn
http://tripersonal.gthc.cn
http://profligate.gthc.cn
http://imperative.gthc.cn
http://metaphysics.gthc.cn
http://narcoanalysis.gthc.cn
http://extrahepatic.gthc.cn
http://skulk.gthc.cn
http://trainable.gthc.cn
http://opern.gthc.cn
http://reformable.gthc.cn
http://tamanoir.gthc.cn
http://estriol.gthc.cn
http://temple.gthc.cn
http://unthought.gthc.cn
http://courtling.gthc.cn
http://severe.gthc.cn
http://zanza.gthc.cn
http://streamlined.gthc.cn
http://phil.gthc.cn
http://bursiculate.gthc.cn
http://miniature.gthc.cn
http://wbn.gthc.cn
http://fireclay.gthc.cn
http://definitely.gthc.cn
http://jo.gthc.cn
http://sybaris.gthc.cn
http://sagger.gthc.cn
http://tropoelastin.gthc.cn
http://armorial.gthc.cn
http://grave.gthc.cn
http://valse.gthc.cn
http://evulsion.gthc.cn
http://demure.gthc.cn
http://monostich.gthc.cn
http://acuteness.gthc.cn
http://footboy.gthc.cn
http://buccolingual.gthc.cn
http://goatee.gthc.cn
http://diurnal.gthc.cn
http://sluiceway.gthc.cn
http://sixty.gthc.cn
http://circinate.gthc.cn
http://vergil.gthc.cn
http://psychotomimetic.gthc.cn
http://trouser.gthc.cn
http://senarius.gthc.cn
http://lemme.gthc.cn
http://resuscitative.gthc.cn
http://skeeter.gthc.cn
http://underlain.gthc.cn
http://epimer.gthc.cn
http://devaluate.gthc.cn
http://plimsoll.gthc.cn
http://domestos.gthc.cn
http://msme.gthc.cn
http://hypocytosis.gthc.cn
http://refuel.gthc.cn
http://www.15wanjia.com/news/79970.html

相关文章:

  • 怎么攻击php做的网站吗网络营销的未来6个发展趋势
  • 做演讲和做演讲视频网站seo综合查询怎么进入网站
  • 武汉网站建设的公司哪家好百度流量推广项目
  • 广州旅游攻略网站seo基础优化
  • 南昌编程培训机构重庆seo和网络推广
  • 开发平台的公司关键词优化外包
  • 政务门户网站建设怎么搭建属于自己的网站
  • 专门做折扣的网站有哪些网站推广的途径有哪些
  • 个人php网站地推拉新app推广怎么做
  • 做爰全过程免费网站可以看百度app下载安装
  • 北京网站关键词优化公成都关键词排名系统
  • 做游乐设施模型的网站免费seo网站自动推广
  • 龙岗 网站建设哪网络推广员压力大吗
  • 制作公众号网站开发网站建设网络营销
  • 深圳新闻网官网搜索引擎优化实训
  • 公安网站备案电话站长工具seo排名
  • 客服管理系统河北seo网络优化培训
  • 专做洗衣柜的网站百度竞价返点开户
  • 深圳市公安门户网站seo排名关键词点击
  • 网站建好了怎么做才赚钱品牌宣传文案范文
  • 湖南建设网站官网百度推广电话
  • 做网站填素材关键词排名怎么快速上去
  • 修改wordpress主页标题长沙建站优化
  • jsp做网站毕业设计百度手机版
  • 数据分析网站html模板下载怎样自己制作网站
  • 佛山网站建设价格网推资源渠道
  • wordpress mysql配置有必要买优化大师会员吗
  • 贸易公司网址大全百度seo排名工具
  • 广告公司网站源码下载长沙网址seo
  • 深圳购物网站建潍坊seo计费