Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <map>
- #include <iostream>
- #include <string>
- #include <vector>
- using LL = long long;
- using namespace std;
- int main() {
- ios_base::sync_with_stdio(false);
- string s;
- cin >> s;
- map<char, LL> cnt;
- for (char c : s)
- cnt[c]++;
- LL res = 0;
- for (char c = 'a'; c <= 'z'; ++c) {
- for (char c2 = 'a'; c2 <= 'z'; ++c2) {
- res += abs(LL(c) - LL(c2)) * cnt[c] * cnt[c2];
- }
- }
- res /= 2;
- cout << res * s.size() << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement