Atcoder Grand Contest 019 B题

  

 1 #include<bits/stdc++.h>
 2 #define maxn 2000100
 3 #define LL long long 
 4 using namespace std;
 5 char str[maxn];
 6 LL num[1000];
 7 int main(){
 8     cin>>str;
 9     int n=strlen(str);
10     LL ans=1;
11     for(int i=0;i<n;i++){
12         ans+=i-num[str[i]];
13         num[str[i]]++;
14     }
15     cout<<ans;
16     return 0;
17 }
原文地址:https://www.cnblogs.com/poler/p/7436839.html