Cod sursa(job #21649)
Utilizator | Data | 23 februarie 2007 22:34:33 | |
---|---|---|---|
Problema | PScPld | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.65 kb |
#include <stdio.h>
#include <string.h>
int C[1000001]; char S[1000001];
int pal( int x, int y )
{
while(x<y)
{
if(S[x] != S[y]) return 0;
++x; -- y;
}
return 1;
}
int main()
{
freopen("pscpld.in", "r", stdin);
freopen("pscpld.out", "w", stdout);
int i, j;
gets(S);
strcpy(S+1, S);
S[0] = '$';
for(i=1; i<strlen(S); ++i)
{
C[i] = C[i-1]+1;
for(j=1; j<i; ++j)
if( pal(j, i) )
++ C[i];
}
printf("%d", C[strlen(S)-1]);
fclose(stdin); fclose(stdout);
return 0;
}