Advertisement
Ritam_C

Google Kickstart Q1

Mar 21st, 2021
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main(){
  5.     ios_base::sync_with_stdio(false);
  6.     cin.tie(NULL);
  7.     int t;
  8.     cin >> t;
  9.     for(int i = 1; i <= t; i++){
  10.         long n, k;
  11.         cin >> n >> k;
  12.         string s;
  13.         cin >> s;
  14.         int c = 0;
  15.         for(int j = 0; j < n/2; j++){
  16.             if(s[j] == s[n-j-1]){
  17.                 c++;
  18.             }
  19.         }
  20.         cout << "Case #" << i << ": " << abs(c-k) << "\n";
  21.     }
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement