0% found this document useful (0 votes)
10 views2 pages

1D Eraser

The document contains C++ code that implements a program to count occurrences of the character 'B' in a string while skipping a specified number of characters after each occurrence. It defines several macros and utility functions, including gcd and lcm. The program reads multiple test cases, processes each string, and outputs the count of 'B's found based on the given rules.

Uploaded by

mo7amed3atf24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

1D Eraser

The document contains C++ code that implements a program to count occurrences of the character 'B' in a string while skipping a specified number of characters after each occurrence. It defines several macros and utility functions, including gcd and lcm. The program reads multiple test cases, processes each string, and outputs the count of 'B's found based on the given rules.

Uploaded by

mo7amed3atf24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include<bits/stdc++.

h>

#define ATEF ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


#define ll long long
#define ull unsigned long long
#define dd double
#define pb push_back
#define ld long double
#define PQ priority_queue
#define pii pair<int,int>
#define pll pair<ll,ll>
#define S second
#define F first
#define MP make_pair
#define ABS(x) ((x) < 0 ? -(x) : (x))
#define DIFF(x, y) ((x) > (y) ? (x) - (y) : (y) - (x))
#define INF 0x3f3f3f3f
#define NEG_INF (-INF)
// Define a macro to set a bit at position i in a number n
#define SET_BIT(n, i) ((n) |= (1 << (i)))
// Define a macro to clear a bit at position i in a number n
#define CLEAR_BIT(n, i) ((n) &= ~(1 << (i)))
// Define a macro to toggle a bit at position i in a number n
#define TOGGLE_BIT(n, i) ((n) ^= (1 << (i)))
// Define a macro to check if a bit at position i in a number n is set
#define IS_SET(n, i) ((n) & (1 << (i)))
#define SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
#define IS_POWER_OF_TWO(n) ((n) && !((n) & ((n) - 1)))
#define IS_NAN(x) ((x) != (x))
#define PI 3.14159265358979323846
#define E 2.71828182845904523536
#define endl "\n"

ll gcd(ll a, ll b) {
return b == 0 ? a : gcd(b, a % b);
}

ll lcm(ll a, ll b) {
return a / gcd(a, b) * b;
}

using namespace std;


const int sz = 1e6 + 1;
int main() {
ATEF
short t;cin>>t;
while(t--)
{
int n,ck,ans{0};cin>>n>>ck;
string s;cin>>s;
for (int i = 0; i < n; ++i) {
if(s[i]=='B')
{
ans++;
i=i+ck-1;
}
}
cout<<ans<<endl;
}
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy