回文串都可以用这个套路做啊!!!
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
String s = input.next();
char[] list = s.toCharArray();
int j=0;
int re=0;
int[][] we = new int[list.length][list.length];
for(int i =0;i<list.length;i++){
we[i][i] = 1;
re++;
}
for(int l =2;l<=list.length;l++){
for(int i = 0 ;i<list.length;i++){
j = l+i -1;
if(j >=list.length){
break;
}
if(list[i] != list[j]){
we[i][j] = 0;
}else{
if(j-i<2){
we[i][j] = 1;
}
else{
we[i][j] = we[i+1][j-1];
}
}
if(we[i][j] == 1){
re++;
}
}
}
System.out.print(re);
}
}