AcWing 3333. K-优字符串
原题链接
简单
作者:
sowei
,
2021-05-23 03:49:15
,
所有人可见
,
阅读 331
import java.util.*;
class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
int caseNumber = 1;
while(t != 0) {
int n = sc.nextInt();
int k = sc.nextInt();
int count = 0;
String str = sc.next();
for(int i = 0, j = str.length() - 1; i < n/2; i++, j--) {
if(str.charAt(i) != str.charAt(j)) count++;
}
int res = Math.abs(k - count);
System.out.println("Case" + " #" + caseNumber + ": " + res);
caseNumber++;
t--;
continue;
}
}
}