Cod sursa(job #553368)
Utilizator | Data | 13 martie 2011 22:38:26 | |
---|---|---|---|
Problema | Litere | Scor | 40 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.43 kb |
#include <cstdio>
#include <fstream>
using namespace std;
int c[27],n,r;
char s[1001];
void solve (){
for(int i=0;i<n;++i){
for(int j=s[i]-'a'+1;j<=25;++j)
r+=c[j];
++c[s[i]-'a'];
}
}
int main ()
{
ifstream in ("litere.in");
in>>n;
in.get();
in.getline(s,1001);
in.close ();
solve ();
freopen ("litere.out","w",stdout);
printf("%d\n",r);
return 0;}