Pagini recente » Cod sursa (job #1055251) | Cod sursa (job #1776768) | Cod sursa (job #2125793) | Cod sursa (job #2705095) | Cod sursa (job #2078235)
#include <bits/stdc++.h>
using namespace std;
const int SIGMA = 26 ;
int litRep [ SIGMA ];
int noLit;
int getRec (int pos ){
int noRep = 0 ;
for( int i = pos + 1; i < SIGMA ; i++ ){
noRep += litRep [ i ];
}
return noRep ;
}
int main(){
freopen("litere.in","r",stdin);
freopen("litere.out","w",stdout);
scanf("%d\n",&noLit);
char lit ;
long long sol = 0 ;
for ( int i = 0 ; i < noLit ; i++ ){
scanf("%c",&lit);
litRep [ lit - 'a' ] ++ ;
sol += getRec( lit - 'a' );
}
printf("%lld",sol);
return 0;
}