版本比较
哈希
正文
增加 8 行删除 8 行
11 行未改动1213141516171819202122239 行未改动33343536373839404142434445464748495051525310 行未改动64656667686970717273747510 行未改动868788899091929311 行未改动for (int i = s.size()-1;i>=0;i--){res = (res+s[i]*base)%mod;base = base * 128 % mod;}return res;}int main(){int n, cnt = 1;cin>>n;9 行未改动if (a[i]!=a[i-1]) cnt++;}cout<<cnt;return 0;}```a3z72Bxy ——ascil码(128/233/277)128^1 128^0* *120 121(a+b)%c = (a%c+b%c)%c哈希冲突:不一样的数经过哈希变得一样10 行未改动#include <iostream>#include <algorithm>#include <unordered_map>using namespace std;unordered_map<int, int> m;//一维数组,下标字符,值整数,无序int main(){//ios::sync_withint t;scanf("%d", &t);//int整数 "lld"long longwhile (t--){10 行未改动printf("%d ", s);}}printf("\n");}return 0;}```11 行未改动1213141516171819202122239 行未改动33343536373839404142434445464748495051525310 行未改动64656667686970717273747510 行未改动868788899091929311 行未改动for (int i = s.size()-1;i>=0;i--){res = (res+s[i]*base)%mod;base = base * 128 % mod;}return res;}int main(){int n, cnt = 1;cin>>n;9 行未改动if (a[i]!=a[i-1]) cnt++;}cout<<cnt;return 0;}```a3z72Bxy ——ascil码(128/233/277)128^1 128^0* *120 121(a+b)%c = (a%c+b%c)%c哈希冲突:不一样的数经过哈希变得一样10 行未改动#include <iostream>#include <algorithm>#include <unordered_map>using namespace std;unordered_map<int, int> m;//一维数组,下标字符,值整数,无序int main(){//ios::sync_withint t;scanf("%d", &t);//int整数 "lld"long longwhile (t--){10 行未改动printf("%d ", s);}}printf("\n");}return 0;}```