题目描述
双11又到了,小Z依然只是一只单身狗,对此他是如此的苦恼又无可奈何。
为了在这一天脱单小Z决定向女神表白,但性格腼腆的小Z决定隐晦一点,截取一段包含’L’、‘O’、‘V’、'E’的英文。(顺序不限)
小Z想起之前小D送给他一本英文书,决定在这里面截取一段话,小Z发现有好多种方案来截取这段话。
你能知道小Z能有多少种方案截取这段话么?
为了简化问题,英文文本讲不会出现空格、换行、标点符号及只有大写的情况。
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String srt;
int[] t = new int[4];
int T = scanner.nextInt();
long sum;
int tem;
while (T-- >0) {
sum = 0;
for (int i = 0; i < 4; i++) {
t[i] = -1;
}
srt = scanner.next();
for (int i = 0; i < srt.length(); i++) {
if (srt.charAt(i)=='L') t[0] = i;
if (srt.charAt(i)=='O') t[1] = i;
if (srt.charAt(i)=='V') t[2] = i;
if (srt.charAt(i)=='E') t[3] = i;
tem = Math.min(Math.min(t[0],t[1]), Math.min(t[2],t[3]));
if (tem != -1) sum += tem+1;
}
System.out.println(sum);
}
}
}