Pagini recente » Cod sursa (job #1118087) | Istoria paginii problema/telefon2 | Statistici FMI Sandu Robert Stelian (thereau) | Statistici Manoli Dan Claudiu (Klaudiu) | 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;
}