#include<iostream>
#include<algorithm>
#include<map>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
string s;
cin >> s;
long long cnt = 0;
int hashmap[128] = {}, pos[128] = {};
for(int i = 0; i < s.length(); i++){
cnt += (i - pos[s[i]] + 1) * (s.length() - i);
hashmap[s[i]]++;
pos[s[i]] = i + 1;
}
printf("%lld\n", cnt);
return 0;
}
第十一届蓝桥杯C++试题 子串分值和
最新推荐文章于 2023-12-03 08:00:00 发布