Codeforces Beta Round #7 D. Palindrome Degree —— hash

AnyGrasp实战指南:从环境配置到抓取检测与跟踪 本文详细介绍了AnyGrasp从环境配置到抓取检测与跟踪的实战指南。涵盖硬件要求、关键依赖安装避坑、抓取检测与跟踪的实战技巧,以及常见问题解决方案和性能优化建议,帮助开发者快速掌握这一高精度物体抓取检测与跟踪技术。 阅读详情

题目链接:http://codeforces.com/contest/7/problem/D


D. Palindrome Degree
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

String s of length n is called k-palindrome, if it is a palindrome itself, and its prefix and suffix of length  are (k - 1)-palindromes. By definition, any string (even empty) is 0-palindrome.

Let's call the palindrome degree of string s such a maximum number k, for which s is k-palindrome. For example, "abaaba" has degree equals to 3.

You are given a string. Your task is to find the sum of the palindrome degrees of all its prefixes.

Input

The first line of the input data contains a non-empty string, consisting of Latin letters and digits. The length of the string does not exceed 5·106. The string is case-sensitive.

Output

Output the only number — the sum of the polindrome degrees of all the string's prefixes.

Examples
input
a2A
output
1
input
abacaba
output
6




代码如下:

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const double eps = 1e-6;
const int INF = 2e9;
const LL LNF = 9e18;
const int mod = 1e9+7;
const int maxn = 5e6+10;

char s[maxn];
int dp[maxn];

int main()
{
    scanf("%s",s+1);
    int l = 0, r = 0, m = 1;
    for(int i = 1; s[i]; i++)
    {
        l = l*137+s[i];
        r = r+s[i]*m, m *= 137;
        if(l==r)
            dp[i] = dp[i/2]+1;
    }

    int ans = 0;
    for(int i = 1; s[i]; i++)
        ans += dp[i];
    printf("%d\n",ans);
}


你不知道的Postman的Mock接口测试,看这一篇就够了 创建Mock服务你可以从Postman已有的测试集(Collection)中创建Mock Server或者直接创建Mock Server(我们这里选择从已有的测试集中创建Mock Server)Mock server详细配置页面,在此页面中我们可以设置:命名Mock Server选择一个环境(可选的),我们可以选择之前设置过的环境,Mock Server将会使用对应环境中设置过的变量在对应的请求和响应中如果想要将Mock Server设置私有访问的,那么可以勾选此选项,不勾选则对所有人可见。 阅读详情

相关推荐

用AI+Playwright实现零代码UI自动化测试:以登录页面为例的实战指南

本文详细介绍了如何利用AI与Playwright结合实现零代码UI自动化测试,特别以登录页面为例进行实战演示。通过自然语言描述生成测试脚本,大幅降低技术门槛,提升测试效率,并支持跨浏览器验证。适合非技术人员快速上手专业级自动化测试。

weixin_28842269的博客 402

Codeforces Beta Round #7--D. Palindrome Degree(hash)

D. Palindrome Degree time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output String s of length n is called k-pali

随风的专栏 1629

Android 性能之 Game Mode

本文的目的是介绍 AOSP Game Mode 功能。Game Mode 功能的核心是系统服务 GameManagerService,在本文中用 GMS 指代 GameManagerService。在 API 26 之后,应用开发者可以通过将应用的 category 属性设置为 "game",使系统(即 GMS)能够将该应用识别为 "游戏"。GMS 定义了 4 种 game mode,即 1|2|3|4|standard|performance|battery|custom;

专注于系统快稳省领域 3064

Codeforces7 D. Palindrome Degree(hash+dp)

题意: 给定字符串,一个(k-回文串)s定义为: s串是回文串,且s[1,n/2]是((k-1)-回文串) (非回文串是(0-回文串)) 要求计算出给定字符串所有前缀的k,并输出他们的k的和 数据范围:n<=5e6 解法: 令d[i]表示s[1,i]的k值 显然d[i]=d[n/2]+1,需要满足s[1,n/2]与s[i-n/2+1,i]互为反串 正向负向都预处理一个hash就能快速判断是否是反串了 code: #include<bits/stdc++.h> using namespac

zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz 325

DS250DF410寄存器配置实战:从原理到调试的高速SerDes信号优化指南

在高速串行通信领域,SerDes(串行器/解串器)技术是实现芯片间高速数据传输的核心。其工作原理是通过时钟数据恢复(CDR)从串行数据流中提取时钟,并利用均衡技术补偿信道损耗。这项技术的核心价值在于突破PCB走线或电缆的带宽限制,确保在25Gbps及以上速率下数据的可靠传输。其应用场景广泛覆盖数据中心、高性能计算和通信设备中的高速背板、光模块及芯片互连。本文以TI的DS250DF410多通道重定时器为例,深入剖析其寄存器配置,特别是如何通过精细调控其自适应均衡器和眼图监测模块,实现对高速链路的信号整形与质量

aodiyi6351的博客 386

第十一届全国大学生GIS应用技能大赛——广西区域发展布局示意图

我们需要制作一幅广西区域发展布局示意图,最终成图参考“数据”文件夹中的广西区域发展布局示意图.png。地图使用的投影坐标系是 Asia_North_Albers_Equal_Area_Conic,其中地理坐标系是China_Geodetic_Coordinate_System_2000,中央经线东经 105°,标准纬线是北纬 25°和北纬 47°,出图比例尺 1:4,780,000。

@HNUSTer的博客 7798

Codeforces Beta Round #7--D. Palindrome Degree(Manacer)

题目:http://blog.csdn.net/winddreams/article/details/44218961 求出每个点为中心的最长字符串,判断该串是不是从开头的回文串。   #include #include #include using namespace std ; int p[12000000] , dp[6000000]; char s[12000000]

随风的专栏 1000

笔试题-2023-星宸-数字IC设计【纯净题目版】

4 笔试题-2023-星宸-数字IC设计【纯净题目版】

w0shishabi的博客 1172

codeforces D. Palindrome Degree(hash)

开始使用Palindromic Characteristics的方式来计算dp(i,j)的回文度,然后统计dp所有(0,j)提示空间超过限制。因为是需要计算所有前缀的回文度之和。由于回文度关系有dp(i) = 1+dp(i/2),如果s[0..i]是回文串。分别计算从0到i和从i到0的哈希值,如果两个哈希值相等,说明是回文串,就用上面的回文度关系。 代码参考: https://github.com/wuli2496/OJ/blob/master/codeforces/D%20Palindrome%20D

多看多听多总结 427

【Bluetooth|蓝牙开发】三、一篇文章,带你总览蓝牙协议

1、开篇词 2、蓝牙开发入门 3、蓝牙协议栈总览 4、蓝牙协议栈——物理层 5、蓝牙协议栈——链路层 6、蓝牙协议栈——传输层 7、蓝牙协议栈——L2CAP协议 8、蓝牙协议栈——ATT协议 9、蓝牙协议栈——GATT协议 10、蓝牙通信流程分析 11、蓝牙协议栈——Bluez交叉编译 12、蓝牙调试工具汇总

Donge's Blog 1万+

[EdgeAI] NXP eIQ 机器学习Toolkit (二):模型篇

eIQ™机器学习(ML)软件开发环境支持在恩智浦EdgeVerse™微控制器和微处理器(包括i.MX RT跨界MCU和i.MX系列应用处理器)上使用ML算法。eIQ ML软件包括称为eIQ Toolkit的ML工作流工具以及推理引擎、神经网络编译器和优化库。......

HowieXue 薛永浩的博客 1万+

[数据结构-hash]CF 7D Palindrome Degree

D. Palindrome Degree time limit per test 1 second String s of length n...

weixin_30737363的博客 161

3.PCIe协议分析1-预备知识点

PCIE协议分析1主要讲一下四方面: PCI-E配置空间 PCI-E地址映射 PCI-E Bar空间 PCI-E层级结构详谈 (1)PCIE配置空间 我们过来学习PCIE的同学应该都接触各种类型的功能芯片吧,这些功能芯片连接在电路里面我们可以认为它是一个外部设备,这些设备里面有自己独有的寄存器区域,比如SDRAM里面的ID寄存器或者其他配置寄存器。好的,其实我们PCIE板卡也相当...

一个早起的程序员 4144

Codeforces Beta Round #7 D. Palindrome Degree hash

D. Palindrome Degree 题目连接: http://www.codeforces.com/contest/7/problem/D Description String s of length n is called k-palindrome, if it is a palindrome itself, and its prefix and suffix of length are ...

weixin_33947521的博客 98

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

Codeforces Beta Round #7 D. Palindrome Degree —— 字符串哈希

题目链接:http://codeforces.com/contest/7/problem/D D. Palindrome Degree time limit per test 1 second memory limit per test 256 megabytes input stan...

weixin_30394633的博客 85

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

Codeforces Beta Round #7 D. Palindrome Degree

D. Palindrome Degree time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output String s of length n is called k-palind

qqspeed 1302

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

Codeforces Beta Round #7, problem: (D) Palindrome Degree

#include #include #include #include __int64 dp[5000000+5]; char s[5000000+5]; using namespace std; int main(void) { __int64 ans=0,l=0,r=0,k=1; scanf("%s",s); for(int i=0;s[i];i++) {

1292765944的专栏 1639

#7 D. Palindrome Degree (manacher + dp)

题目链接: 点击打开链接 http://codeforces.com/contest/7/problem/D D. Palindrome Degree String s of length n is called k-palindrome, if it is a palindrome itself, and its prefix and su

LzyRapX 799

Codeforces 7D Palindrome Degree 字符串hash DP

传送门:点击打开链接 D. Palindrome Degree time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output String s of length n is called k-palindrome, if

上决╇ф的ACM 1221

CODEFORCES 501E Misha and Palindrome Degree <回文串 + 构成回文串的种数>

传送门:http://codeforces.com/problemset/problem/501/E 题意:给你n个数字a0,a2,...,an-1。(1 分析:列举每种可能匹配的情况,分奇偶,注意中间位置 考虑周全就行了。。。。。代码如下: #include using namespace std; const int maxn = 100005; int a[maxn],b[max

论菜鸟的自我修养。。。 911

CF 7D: Palindrome Degree

题目链接:http://codeforces.com/contest/7/problem/D 题意: “等级”的定义是, 若一个长度为len的前缀是回文串, 且它的长度为floor(len/2)的前缀和后缀的“等级”为k, 则它的等级是k+1。 求一个字符串所有前缀的“等级”和。 算法: 我是用manacher算法求的回文串。 manacher算法的介绍很多,比如

frog的小池塘 2027

codeforces 7D Palindrome Degree

题目链接:http://codeforces.com/problemset/problem/7/D 题意:(1)任何串(包括空串)都是0-回文; (2)一个长度为n的回文串,若它的前n/2个字符和后n/2个字符都是(k-1)-回文,则它是k-回文。现给定一个串,设它的前缀分别是x-回文,求所有这些x值的和。 比如: abacaba 前缀                    x a  

Yedl的专栏 1128

Educational Codeforces Round 7 D. Optimal Number Permutation 构造题

D. Optimal Number Permutation 题目连接: http://www.codeforces.com/contest/622/problem/D Description You have array a that contains all integers from 1 to n twice. You can arbitrary permute any numbers in ...

weixin_33779515的博客 197

Codeforces Round #285 (Div. 2) E. Misha and Palindrome Degree 二分+容斥

E. Misha and Palindrome Degree time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Misha has an array of n integ

野生的声威的专栏 1209

codeforces 1187D

传送门:https://codeforces.com/problemset/problem/1187/D 比赛中写了个假的FST了,不过还好E题是个水题而且写得够快,还是上了一大波分 那天晚上网友给了个hack数据 5 1 3 5 4 2 1 2 3 5 4 这个是YES,然后我就发现我没了,然后去hack了十多个人,结果发现edu赛后hack不加分。。。 后来补题瞄了一眼题解,发现把整...

binarycopycode 472

codeforces 7C Line

题意:给条直线方程,Ax+By+C=0问是否存在整数x,y满足方程.存在任意输出,否则输出-1 思路;直接套欧几里得解出来。 #include #define ll long long using namespace std; void exgcd(ll a,ll b,ll &d,ll &x,ll &y) { if(!b) { x=1;y=0;d=a; } else { ex

chen_minghui的博客 445
上一篇: VK Cup 2012 Qualification Round 1 E. Phone Talks —— DP
下一篇: Codeforces Round #394 (Div. 2) B. Dasha and friends —— 暴力 or 最小表示法
DOLFAMINGO
博客等级 码龄10年 8粉丝 216原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值