A7798 | Palindrome Degree
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
回文度
**题目描述**
前置知识:一个字符串与这个字符串反转后相等,则这个字符串是一个回文字符串。
一个长度为n的字符串s叫做k-palindrome当这个字符串是一个回文字符串。与此同时,这个字符串的长度为$\lceil n/2 \rceil$被称之为$k-1$-palindromes。根据定义,任何字符串(包括但不限于空字符串)也是$0$-palindrome。
一个字符串的回文度是一个字符串中最长的回文字串的长度。例如字符串
你的任务是找出这个字符串的所有前缀的回文度之和。
感谢[Macw](https://www.acgo.cn/person/929871)提供翻译
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.
回文度
**题目描述**
前置知识:一个字符串与这个字符串反转后相等,则这个字符串是一个回文字符串。
一个长度为n的字符串s叫做k-palindrome当这个字符串是一个回文字符串。与此同时,这个字符串的长度为$\lceil n/2 \rceil$被称之为$k-1$-palindromes。根据定义,任何字符串(包括但不限于空字符串)也是$0$-palindrome。
一个字符串的回文度是一个字符串中最长的回文字串的长度。例如字符串
”abaabc”的度即位$3$。你的任务是找出这个字符串的所有前缀的回文度之和。
感谢[Macw](https://www.acgo.cn/person/929871)提供翻译
输入格式
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·10^{6}$ . The string is case-sensitive.
输入一行一个长度不超过$5*10^6$的字符串。保证字符串仅包括拉丁大小写字符以及数字字符。该字符串是大小写敏感的。
输入一行一个长度不超过$5*10^6$的字符串。保证字符串仅包括拉丁大小写字符以及数字字符。该字符串是大小写敏感的。
输出格式
Output the only number — the sum of the polindrome degrees of all the string's prefixes.
输出一行一个整数,表示输入字符串的所有前缀的回文度之和。
输出一行一个整数,表示输入字符串的所有前缀的回文度之和。
输入输出样例
输入 #1
a2A
输出 #1
1
输入 #2
abacaba
输出 #2
6
**请注意,本题的空间限制为256MB,是默认空间限制的两倍**
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted