Cod sursa(job #508945)
Utilizator | dumitriu florin florin_d | Data | 9 decembrie 2010 23:00:42 |
---|---|---|---|
Problema | PScPld | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.52 kb |
#include <iostream>
#include <fstream>
int n;
char a[1000000];
using namespace std;
int main() {
int n = -1, numar = 0, x, y;
char c;
ifstream fin("pscpld.in");
ofstream fout("pscpld.out");
while(fin>>c) a[++n] = c;
cout<<a;
for(int i = 1 ; i <= n; i++) {
x = i -1;
y = i;
while( x >= 0 && y <= n && a[x] == a[y]) {
--x;++y;++numar;
}
x = i - 1;
y = i + 1;
while( x >= 0 && y <= n && a[x] == a[y]) {
--x;++y;++numar;
}
}
numar += n + 1;
fout<<numar;
return 0;
}