字符串模拟赛T1
2024-08-29 17:32:51
// source code from laekov for c0x17
#define PRID "bxjl"
#include <cstdio>
#include <cstring>
#include <algorithm> using namespace std; typedef long long dint; const int maxn = ;
const int mod = ; char a[maxn];
int n, m, ne[maxn], sz[maxn]; void preNext() {
ne[] = ;
for (int i = , j = ; i <= n; ++ i) {
for (; j && a[i] != a[j + ]; j = ne[j]);
if (a[i] == a[j + ] && j + < i) {
ne[i] = ++ j;
} else {
ne[i] = ;
}
}
memset(sz, , sizeof(sz));
for (int i = n; i; -- i) {
++ sz[i];
sz[ne[i]] += sz[i];
}
} int main(int argc, char* args[]) {
if (argc < || strcmp(args[], "-nf")) {
freopen(PRID ".in", "r", stdin);
freopen(PRID ".out", "w", stdout);
}
scanf("%s", a + );
n = strlen(a + );
preNext();
dint ans();
for (int i = ; i <= n; ++ i) {
ans += sz[i];
}
printf("%d\n", (int)(ans % mod));
}
最新文章
- HTML5 学习总结(五)——WebSocket与消息推送
- ios 防止按钮快速点击造成多次响应的避免方法。
- loadrunner写入数据到文件
- springMVC使用注解方式进行页面跳转
- [大牛翻译系列]Hadoop(17)MapReduce 文件处理:小文件
- linux vncserver配置
- bzoj1257
- asterisk错误排查
- TCP:三次握手、四次握手、backlog及其他
- npm 一条命令更换淘宝源
- poj 3696 The Luckiest Number
- Spring Boot web简介及原理 day04
- win10 WSL kali 下载源 --另外 恭喜马哥喜提博客
- c# EF code First生成数据库以及表
- zipkin 整合elastic
- P1378 油滴扩展 dfs回溯法
- CentOS 通过yum在线安装MySQL5.7
- Cartographer源码阅读(6):LocalTrajectoryBuilder和PoseExtrapolator
- nrf52832 SDK 15.3.0 Flash 操作
- linux_vim