当前位置:网站首页>【集训DAY15】好名字【hash】
【集训DAY15】好名字【hash】
2022-07-25 22:24:00 【VL——MOESR】

思路:
直接一个hash判断是否出现就行了
c o d e code code
#include<iostream>
#include<cstdio>
#include<cstring>
typedef unsigned long long ull;
using namespace std;
ull pow[400010], has[400010], mod = 127;
char s[400010];
int main() {
scanf("%s", s + 1);
int n = strlen(s + 1);
pow[0] = 1;
for(int i = 1; i <= n; i ++) pow[i] = pow[i - 1] * mod, has[i] = has[i - 1] * mod + ull(s[i] - 'A' + 1);
for(int i = 1; i <= n; i ++) {
ull ha = has[n] - has[n - i] * pow[i];
if(ha == has[i] && ha != 0) printf("%d ", i);
}
return 0;
}
边栏推荐
猜你喜欢

QML module not found

Fill the whole square with the float property

沃达德软件:智慧城市方案

Ffmpeg plays audio and video, time_ Base solves the problem of audio synchronization and SDL renders the picture

The third day of Xiaobai programmer

完啦,上班三个月,变秃了

Arcgis10.2 configuring postgresql9.2 standard tutorial

Don't vote, software testing posts are saturated

MySQL - subquery - column subquery (multi row subquery)

If jimureport building block report is integrated according to the framework
随机推荐
MySQL --- 子查询 - 列子查询(多行子查询)
淦,为什么 '𠮷𠮷𠮷' .length !== 3 ??
科大讯飞智能办公本Air电纸书阅读器,让我的工作生活更加健康
Some summary about function
About vscode usage+ Solutions to the problem of tab failure
torchvision
ArcGIS10.2配置PostgreSQL9.2标准教程
Win10 set up a flutter environment to step on the pit diary
QML module not found
字符型常量和字符串常量的区别?
SMART S7-200 PLC通道自由映射功能块(DO_Map)
Mitsubishi FX PLC free port RS command realizes Modbus Communication
If jimureport building block report is integrated according to the framework
mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No suc
点亮字符串中所有需要点亮的位置,至少需要点几盏灯
If it is modified according to the name of the framework module
Basic principle of torque motor control
3 词法分析
IFLYTEK smart office book air e-book reader makes my work life healthier
Math programming classification