HBC244823虚空之力,贪心Hash题解 (每日一词:string)

不可一世的小女人 算法基础篇 29 0
题库丰富多样,涵盖各个领域,全网最全C++题库,让您在练习中不断成长!
Lucy is learning string hash algorithm . For a given string SSS , she will execute the following code to get it's hash code . //LanguageC++14. } Ruby thinks the value of mod is not big enough , so he decides to generate a string TTT meets the following conditions . 1. TTT only contains lowercase English letters . 2. SSS is a prefix of TTT . 3. Hash code of SSS and TTT are the same . 4. 1≤∣T∣∣S∣≤501leq |T|-|S|leq 501≤∣T∣∣S∣≤50 . ∣S∣|S|∣S∣ means the length of string SSS .

Lucy is learning string hash algorithm . For a given string SSS , she will execute the following code to get it's hash code . //Language C++14 long long mod=5999993; long long gethas(string s) { long long ret=0; for (char c:s) ret=(ret*29+(c-'a'+1))%mod; return ret; } Ruby thinks the value of mod is not big enough , so he decides to generate a string TTT meets the following conditions . 1. TTT only contains lowercase English letters . 2. SSS is a prefix of TTT . 3. Hash code of SSS and TTT are the same . 4. 1≤∣T∣−∣S∣≤501leq |T|-|S|leq 501≤∣T∣−∣S∣≤50 . ∣S∣|S|∣S∣ means the length of string SSS .

HBC244823虚空之力,贪心Hash题解
(每日一词:string)-第1张图片-东莞河马信息技术
(图片来源网络,侵删)

标签: HBC244823虚空之力 贪心Hash题解