Cod sursa(job #2111599)
| Utilizator | Data | 22 ianuarie 2018 13:45:05 | |
|---|---|---|---|
| Problema | Litere | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.47 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("litere.in");
ofstream fout("litere.out");
unsigned long long answer;
char s[10005];
int n, vf[32];
int main()
{
int i, j, l;
bool ok;
fin>>n;
fin.get();
fin.getline(s,sizeof(s));
l=strlen(s)-1;
for(i=0; i<=l; i++)
{
vf[s[i]-'a']++;
for(j=s[i]-'a'+1; j<='z'-'a'; j++) answer+=(unsigned long long)vf[j];
}
fout<<answer<<'\n';
return 0;
}
